slashback100 / presence_simulation

Home Assistant Presence Simulation
423 stars 22 forks source link

KeyError: 'random' #121

Closed adorobis closed 3 months ago

adorobis commented 3 months ago

I'm getting the following error in the log. I'm on HA 2024.4.0, Docker installation. Don't know if it was there before HA upgrade though.

2024-04-04 08:32:01.319 ERROR (MainThread) [homeassistant.components.switch] Error while setting up presence_simulation platform for switch
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 356, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/presence_simulation/switch.py", line 28, in async_setup_entry
    async_add_devices([PresenceSimulationSwitch(hass, config_entry)], True)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/presence_simulation/switch.py", line 34, in __init__
    self.update_config(config)
  File "/config/custom_components/presence_simulation/switch.py", line 57, in update_config
    self._random = int(config.data["random"])
                       ~~~~~~~~~~~^^^^^^^^^^
KeyError: 'random'
slashback100 commented 3 months ago

Strange... It says that the random parameter could not be found in the configuration, while it is a mandatory parameter. Could you please try to edit and save your Presence Simulation integration and see if it fix the issue? I'm also on 2024.4.0 but I don't have the issue.

adorobis commented 3 months ago

Yeah, I've actually done that in the mean time and indeed the error is gone. Maybe this parameter was introduced after I have enabled this integration long time ago.