Unable to find referenced entities
Every time I turn a remote switch on and off from the master HA, I get the message "Unable to find referenced entities switch.mp20z_switch_2". This switch is on the remote HA and is part of a ZWAVE plug I have set up on the remote instance. The switch works fine, I just see this warning message in the log every time I turn it on an off.
Any help would be appreciated.
Thank you.
Logger: homeassistant.helpers.service Source: helpers/service.py:130 First occurred: 1:30:29 PM (2 occurrences) Last logged: 1:30:32 PM
Unable to find referenced entities switch.mp20z_switch_2
Hi, I have also this problem on main instance - entities from remote instances which are used on automations are affected
I also have this issue.
I just saw this as well.
This is because remote_homeassistant creates local states for remote devices but no local platforms are associated to these. Therefore when a service is called on a remote entity:
- remote_homeassistant sees that event and forward it to the remote side [OK]
- homeassistant core service handler (helpers/service.py#L534) sees the same event but is unable to find a local platform/device instantiating the referenced entity helpers/service.py#L634 and issue a warning as a consequence [NOK]
This warning is only visible when the service is called, e.g. using the UI, from the master instance (states are associated to real platforms on slave instances, i.e. platform service is effectively called).
To convince yourself, you can create a state without platform using the "Developper Tools"->"States"; enter e.g. switch.fake as entity and off as state. You can now use it in your UI and when you toggle the switch you get the same message.
In order to address this HA should perhaps add a new boolean state attribute, e.g. state.attributes.virtual that could be used by the core handler to ignore service calls on such entities ...
To workaround this issue, I added the following lines before helpers/service.py#L634:
if not target_all_entities:
assert referenced is not None
# Only report on explicit referenced entities
missing = set(referenced.referenced)
#<-- from here Remove entities marked as virtual
for entity in referenced.referenced:
if hass.states.get(entity).attributes.get("virtual",False):
missing.discard(entity)
#--> to here
for entity in entity_candidates:
missing.discard(entity.entity_id)
referenced.log_missing(missing)
and modified the configuration.yaml of the master instance to add the virtual attribute to all remote entities (only one/input_boolean.test here)
homeassistant:
customize:
input_boolean.test:
virtual: true
In the "Developper Tools"->"States", you can now see a virtual=true attribute for remote entities (only on the master instances) and no more "Unable to find referenced entities" logs as expected.