slashback100 / presence_simulation

Home Assistant Presence Simulation
423 stars 22 forks source link

Covers #94

Closed sciorty closed 5 months ago

sciorty commented 10 months ago

I start a simulation eith the following service call inside an automation:

service: presence_simulation.start
data:
  entity_id:
    - light….
    - cover.serranda_bagno
    - cover.serranda_cameretta
    - cover.serranda_soggiorno
  delta: 7
  restore_states: false
  random: 300

But i noticed that the covers are not fully closed/opened like they were in the 7 days before, but rather set on a certain randome percentage.

Is that normal?

slashback100 commented 10 months ago

No it is not. Could you activate the log, reproduce and send me the log? I guess the problems comes from the fact that, unlike lights, covers take time to change their status, and the time difference between the opening/closing command and the state being changed in HA could lead to such behavior.

sciorty commented 10 months ago

I enabled the debug recording in the integration settings:

image

But maybe i’m not looking in the right places for the log. I only found this warnings for the covers where i suspect they should be opened from the simulation: image

sciorty commented 9 months ago

Any idea?

slashback100 commented 9 months ago

Can you activate the log this way and reproduce?

sciorty commented 9 months ago

I think i did throug the interface but to be sure i did via the service call. Now where should i look at? where is the log?

slashback100 commented 9 months ago

It depends on your installation (core, OS, supervised or container) https://community.home-assistant.io/t/where-does-home-assistant-wirte-the-logs/5989/6

sciorty commented 9 months ago

Ok i just had to download the file, apparently it was not visible from the web interface. Logger was already enabled and the error is the same I posted before. Here an example of what i see in a certain curtain

2023-08-15 06:59:24.599 DEBUG (MainThread) [custom_components.presence_simulation] Switching Cover cover.serranda_bagno to open
2023-08-15 06:59:24.600 DEBUG (MainThread) [custom_components.presence_simulation] Changing cover cover.serranda_bagno position to 20.0
2023-08-15 06:59:24.609 DEBUG (MainThread) [custom_components.presence_simulation] State {'entity_id': 'cover.serranda_bagno', 'state': 'open', 'attributes': {'current_position': 30.0, 'friendly_name': 'Serranda Bagno'}, 'last_changed': '2023-08-08T04:58:43.649190+00:00', 'last_updated': '2023-08-08T04:58:46.468101+00:00'}
2023-08-15 06:59:24.609 DEBUG (MainThread) [custom_components.presence_simulation] Switch of cover.serranda_bagno foreseen at 2023-08-15 04:58:46.468101+00:00
2023-08-15 06:59:24.610 DEBUG (MainThread) [custom_components.presence_simulation] Randomize the event of -114.89147865511137 seconds
2023-08-15 06:59:24.610 DEBUG (MainThread) [custom_components.presence_simulation] Switching Cover cover.serranda_bagno to open
2023-08-15 06:59:24.610 DEBUG (MainThread) [custom_components.presence_simulation] Changing cover cover.serranda_bagno position to 30.0
2023-08-15 06:59:24.617 DEBUG (MainThread) [custom_components.presence_simulation] State {'entity_id': 'cover.serranda_bagno', 'state': 'open', 'attributes': {'current_position': 40.0, 'friendly_name': 'Serranda Bagno'}, 'last_changed': '2023-08-08T04:58:43.649190+00:00', 'last_updated': '2023-08-08T04:58:47.865277+00:00'}
2023-08-15 06:59:24.618 DEBUG (MainThread) [custom_components.presence_simulation] Switch of cover.serranda_bagno foreseen at 2023-08-15 04:58:47.865277+00:00
2023-08-15 06:59:24.619 DEBUG (MainThread) [custom_components.presence_simulation] Randomize the event of -183.85939811192634 seconds
2023-08-15 06:59:24.619 DEBUG (MainThread) [custom_components.presence_simulation] Switching Cover cover.serranda_bagno to open
2023-08-15 06:59:24.619 DEBUG (MainThread) [custom_components.presence_simulation] Changing cover cover.serranda_bagno position to 40.0
2023-08-15 06:59:24.626 DEBUG (MainThread) [custom_components.presence_simulation] State {'entity_id': 'cover.serranda_bagno', 'state': 'open', 'attributes': {'current_position': 50.0, 'friendly_name': 'Serranda Bagno'}, 'last_changed': '2023-08-08T04:58:43.649190+00:00', 'last_updated': '2023-08-08T04:58:49.464889+00:00'}
2023-08-15 06:59:24.626 DEBUG (MainThread) [custom_components.presence_simulation] Switch of cover.serranda_bagno foreseen at 2023-08-15 04:58:49.464889+00:00
2023-08-15 06:59:24.627 DEBUG (MainThread) [custom_components.presence_simulation] Randomize the event of 235.16842393994443 seconds
2023-08-15 06:59:24.630 WARNING (MainThread) [homeassistant.helpers.script.serranda_bagno] Serranda Bagno: Already running
2023-08-15 06:59:24.637 WARNING (MainThread) [homeassistant.helpers.script.serranda_bagno] Serranda Bagno: Already running

So they stop afer home assistant says "already running". I see that the simulator gradually changes the opening position from 10 to 10 ( or maybe that's what it registered and then replayed). Couldn't it just set the final position (or register the positions with more intervals) ?

slashback100 commented 9 months ago

Yep apparently in your history, you have those intermediate position states. And since you are using the random feature, the behavior will not be as expected. Did you tried without the random feature? No it can't just bypass the intermediary positions. The plugin is not intelligent, it just repeats what happened.

sciorty commented 9 months ago

No i did not try to remove the random feature, but i will, even if that was a very nice feature. Can it be disabled just for the covers? Also, i just noticed that also the TV had some problems, in fact i've never seen it on. I don't know why but it is always toggling from available to unavailable during the day. Do you think that the randomization causes some issue here as well?

2023-08-15 07:25:28.349 DEBUG (MainThread) [custom_components.presence_simulation] Switching media_player media_player.android_tv_192_168_1_104 to off
2023-08-15 07:25:28.352 DEBUG (MainThread) [custom_components.presence_simulation] State {'entity_id': 'media_player.android_tv_192_168_1_104', 'state': 'unavailable', 'attributes': {'device_class': 'tv', 'friendly_name': 'tv salone'}, 'last_changed': '2023-08-08T05:22:13.682712+00:00', 'last_updated': '2023-08-08T05:22:13.682712+00:00'}
2023-08-15 07:25:28.353 DEBUG (MainThread) [custom_components.presence_simulation] Switch of media_player.android_tv_192_168_1_104 foreseen at 2023-08-15 05:22:13.682712+00:00
2023-08-15 07:25:28.353 DEBUG (MainThread) [custom_components.presence_simulation] Randomize the event of -22.080441887537404 seconds
2023-08-15 07:25:28.353 DEBUG (MainThread) [custom_components.presence_simulation] Switching media_player media_player.android_tv_192_168_1_104 to unavailable
2023-08-15 07:25:28.353 DEBUG (MainThread) [custom_components.presence_simulation] State in unavailable, do nothing
2023-08-15 07:25:28.353 DEBUG (MainThread) [custom_components.presence_simulation] State {'entity_id': 'media_player.android_tv_192_168_1_104', 'state': 'off', 'attributes': {'adb_response': None, 'hdmi_input': None, 'device_class': 'tv', 'friendly_name': 'tv salone'}, 'last_changed': '2023-08-08T05:22:15.398638+00:00', 'last_updated': '2023-08-08T05:22:15.398638+00:00'}
2023-08-15 07:25:28.353 DEBUG (MainThread) [custom_components.presence_simulation] Switch of media_player.android_tv_192_168_1_104 foreseen at 2023-08-15 05:22:15.398638+00:00
2023-08-15 07:25:28.353 DEBUG (MainThread) [custom_components.presence_simulation] Randomize the event of -214.73415273378225 seconds
2023-08-15 07:25:28.354 DEBUG (MainThread) [custom_components.presence_simulation] Switching media_player media_player.android_tv_192_168_1_104 to off
2023-08-15 07:25:28.358 DEBUG (MainThread) [custom_components.presence_simulation] State {'entity_id': 'media_player.android_tv_192_168_1_104', 'state': 'unavailable', 'attributes': {'device_class': 'tv', 'friendly_name': 'tv salone'}, 'last_changed': '2023-08-08T05:22:32.857838+00:00', 'last_updated': '2023-08-08T05:22:32.857838+00:00'}
2023-08-15 07:25:28.358 DEBUG (MainThread) [custom_components.presence_simulation] Switch of media_player.android_tv_192_168_1_104 foreseen at 2023-08-15 05:22:32.857838+00:00
2023-08-15 07:25:28.358 DEBUG (MainThread) [custom_components.presence_simulation] Randomize the event of 32.38690495933099 seconds
2023-08-15 07:25:28.358 DEBUG (MainThread) [custom_components.presence_simulation] Switching media_player media_player.android_tv_192_168_1_104 to unavailable
2023-08-15 07:25:28.359 DEBUG (MainThread) [custom_components.presence_simulation] State in unavailable, do nothing
2023-08-15 07:25:28.359 DEBUG (MainThread) [custom_components.presence_simulation] State {'entity_id': 'media_player.android_tv_192_168_1_104', 'state': 'off', 'attributes': {'adb_response': None, 'hdmi_input': None, 'device_class': 'tv', 'friendly_name': 'tv salone'}, 'last_changed': '2023-08-08T05:22:36.058878+00:00', 'last_updated': '2023-08-08T05:22:36.058878+00:00'}
2023-08-15 07:25:28.359 DEBUG (MainThread) [custom_components.presence_simulation] Switch of media_player.android_tv_192_168_1_104 foreseen at 2023-08-15 05:22:36.058878+00:00
2023-08-15 07:25:28.359 DEBUG (MainThread) [custom_components.presence_simulation] Randomize the event of 213.16663562923088 seconds
2023-08-15 07:25:38.525 ERROR (MainThread) [homeassistant.components.androidtv.media_player] Failed to execute an ADB command. ADB connection re-establishing attempt in the next update. Error: Reading from 192.168.1.104:5555 timed out (9.0 seconds)
2023-08-15 07:25:38.529 ERROR (MainThread) [homeassistant.helpers.entity] Update for media_player.android_tv_192_168_1_104 fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 559, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 784, in async_device_update
    await self.async_update()
  File "/usr/src/homeassistant/homeassistant/components/androidtv/media_player.py", line 170, in _adb_exception_catcher
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/androidtv/media_player.py", line 490, in async_update
    ) = await self.aftv.update(self._get_sources)
slashback100 commented 9 months ago

No it is not possible to disable random feature for covers only. In your historic, we see the Tv was unavailable, then off, then unavailable, then off. So the simulation doesn't turn it on. Is the state of your TV realy 'on' when it is actually on?

stefanbode commented 6 months ago

Hi. I just saw you post regarding the covers. Are you using Tasmota to control the covers? In this case I may have an idea as I wrote the driver and for sure it was not intended that during movement you get all the vale's back. Also adding some random minutes to the values will cause they do not come in the right order. This may explain it also. First I would try without the random timeshift.