slashback100 / presence_simulation

Home Assistant Presence Simulation
423 stars 22 forks source link

Presence simulation stops with invalid entities #60

Closed msm8811 closed 2 years ago

msm8811 commented 2 years ago

When I trigger the simulation to start, I always get this error:

Logger: custom_components.presence_simulation Source: custom_components/presence_simulation/init.py:182 Integration: Presence Simulation (documentation, issues) First occurred: June 14, 2022, 8:17:47 AM (4 occurrences) Last logged: 10:18:11 PM

Error during identifing entities, no valid entities has been found

I have tried making groups with the new groups helper, and it fails with this error. If I take the 30 or so lights and put them all on the entities list (separated by commas) during configuration, I get this error too. This is all with 2022.6.6.

slashback100 commented 2 years ago

Could you set the error level to debug, activate the simulation and send me the log please?

msm8811 commented 2 years ago

I don't see any debug options that are configurable in the integration. How do I set that level of error reporting?

slashback100 commented 2 years ago

You can call the logger.set_level service :

service: logger.set_level
data:
    custom_components.presence_simulation: debug
msm8811 commented 2 years ago

Here are the logs when I have just one light entry configured and try and turn it on:

2022-06-30 12:20:55 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=switch, service=turn_on, service_data=entity_id=switch.presence_simulation> 2022-06-30 12:20:55 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event call_service[L]: domain=switch, service=turn_on, service_data=entity_id=switch.presence_simulation>) 2022-06-30 12:20:55 DEBUG (SyncWorker_5) [custom_components.presence_simulation.switch] Turn on of the presence simulation through the switch 2022-06-30 12:20:55 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event call_service[L]: domain=presence_simulation, service=start, service_data=> 2022-06-30 12:20:55 DEBUG (MainThread) [custom_components.presence_simulation] Is already running ? off 2022-06-30 12:20:55 DEBUG (MainThread) [custom_components.presence_simulation] setting restore states False 2022-06-30 12:20:55 DEBUG (MainThread) [custom_components.presence_simulation] Presence simulation started 2022-06-30 12:20:55 ERROR (MainThread) [custom_components.presence_simulation] Error when trying to identify entity light.bridge_bridge_wall_wash, it seems it doesn't exist. Continuing without this entity 2022-06-30 12:20:55 ERROR (MainThread) [custom_components.presence_simulation] Error during identifing entities, no valid entities has been found 2022-06-30 12:20:55 DEBUG (Recorder) [homeassistant.components.recorder.core] Processing task: EventTask(event=<Event call_service[L]: domain=presence_simulation, service=start, service_data=>)

That entity, light.bridge_bridge_wall_wash is one of many lutron lights and I assure you it exists and is controlld by home assistant just fine. I get the same error when I try and use multiple entities as well.

slashback100 commented 2 years ago

Well that's strange... The code is the following:

if hass.states.get(entity) is None:
    _LOGGER.error("Error when trying to identify entity %s, it seems it doesn't exist. Continuing without this entity", entity)

It this error is raised, it means the entity is not found in hass.states, which, as far as I know, is only supposed to happen if the entity doesn't exist...

slashback100 commented 2 years ago

The get method of the hass.states object :

    def get(self, entity_id: str) -> State | None:
        """Retrieve state of entity_id or None if not found.

        Async friendly.
        """
        return self._states.get(entity_id.lower())

https://github.com/home-assistant/core/blob/a58301a97d7f90a791643607eff0ed74d5f59eb9/homeassistant/core.py#L1303-L1308

slashback100 commented 2 years ago

So if you type

{{ states.light.bridge_bridge_wall_wash.state }}
{{ states('light.bridge_bridge_wall_wash') }}

in Template screen, what do you get?

msm8811 commented 2 years ago

Thanks for working this.

When I type this into the templates screen, I get

off off

in the results window.

msm8811 commented 2 years ago

Did you fix something in this release from yesterday (v2.1) ? The integration seems to not be throwing errors as before when activated. I have a light group and individual lights work. However, if I have multiple entities on the UI based config, light light.lights_ps, and cover.covers_ps, it fails aagin.

How are you supposed to add multiple entities on the configuration UI? Multiple entities separated by a comma?

slashback100 commented 2 years ago

Nop, didn't change anything concerning your issue... If you want to add several entities, you have to create group.

msm8811 commented 2 years ago

Sorry, I don't understand the limitation. You can't create a group with both covers and lights, or switches and lights - they all have to be in the same domain. If I want to have both covers, lights, etc.. all be simulated, don't you have to be able to add multiple entities in the configuration?

slashback100 commented 2 years ago

Hmm ok I understand. Actually I'm using groups that are apparently 'old fashion` that allows to group entities from different domains... And that is not possible anymore. I will then think about something to allows that...

slashback100 commented 2 years ago

62 created

slashback100 commented 2 years ago

Support for multiple entities added in v2.2

msm8811 commented 2 years ago

This seems to work fine. Thanks for the fix!