benleb / ad-automoli

💡 Fully automatic light management based on conditions like motion, illuminance, humidity, and other clever features
https://github.com/benleb/ad-automoli
MIT License
108 stars 29 forks source link

Error setting up automoli when omitting daytimes twice #87

Open paviro opened 2 years ago

paviro commented 2 years ago

😩 Describe the issue/bug When setting up two instances of automoli without a daytime array the second one fails for some reason. When removing either one the other one works. When both are there the last one fails with the attached error.

The part that fails is actually my code but I am really unsure why it only fails when a second instance is used without a daytime array = why in that case the starttime already is a datetime object instead of a string.

😒 Expected behavior It should always fail or never and not only when using two instances without daytime.

🎛️ Configuration

balkon_bewegungsmelder:
  module: automoli
  class: AutoMoLi
  room: Balkon
  delay: 30

  disable_switch_entities:
    - input_boolean.bewegungsmelder
    - input_boolean.bewegungsmelder_aussen
  disable_switch_states: "off"

  illuminance: sensor.balkon_helligkeit
  illuminance_threshold: 45

  motion_state_on: "on"
  motion_state_off: "off"
  motion:
    - binary_sensor.balkon_bewegung

  lights:
    - light.balkon_wand

  dim:
    method: transition
    seconds_before: 10

terrasse_bewegungsmelder:
  module: automoli
  class: AutoMoLi
  room: Terrasse
  delay: 30

  disable_switch_entities:
    - input_boolean.bewegungsmelder
    - input_boolean.bewegungsmelder_aussen
  disable_switch_states: "off"

  illuminance: sensor.terrasse_helligkeit
  illuminance_threshold: 45

  motion_state_on: "on"
  motion_state_off: "off"
  motion:
    - binary_sensor.terrasse_bewegung

  lights:
    - light.terrasse_wand

  dim:
    method: transition
    seconds_before: 10

🧠 System

🗒️ Logs

2021-10-03 20:00:43.373596 INFO balkon_bewegungsmelder: 💡 AutoMoLi v0.11.2 · Balkon
2021-10-03 20:00:43.377636 INFO balkon_bewegungsmelder:  
2021-10-03 20:00:43.381903 INFO balkon_bewegungsmelder:    room: Balkon
2021-10-03 20:00:43.385993 INFO balkon_bewegungsmelder:    delay: 0:30min ≈ 30sec
2021-10-03 20:00:43.390119 INFO balkon_bewegungsmelder:    active_daytime: day
2021-10-03 20:00:43.394212 INFO balkon_bewegungsmelder:    daytimes:
2021-10-03 20:00:43.398562 INFO balkon_bewegungsmelder:      morning:
2021-10-03 20:00:43.402925 INFO balkon_bewegungsmelder:        starttime: 05:30:00
2021-10-03 20:00:43.407450 INFO balkon_bewegungsmelder:        light: 25
2021-10-03 20:00:43.411605 INFO balkon_bewegungsmelder:      day:
2021-10-03 20:00:43.416072 INFO balkon_bewegungsmelder:        starttime: 07:30:00
2021-10-03 20:00:43.420326 INFO balkon_bewegungsmelder:        light: 100
2021-10-03 20:00:43.424745 INFO balkon_bewegungsmelder:      evening:
2021-10-03 20:00:43.430002 INFO balkon_bewegungsmelder:        starttime: 20:30:00
2021-10-03 20:00:43.435040 INFO balkon_bewegungsmelder:        light: 90
2021-10-03 20:00:43.439715 INFO balkon_bewegungsmelder:      night:
2021-10-03 20:00:43.444301 INFO balkon_bewegungsmelder:        starttime: 22:30:00
2021-10-03 20:00:43.448635 INFO balkon_bewegungsmelder:        light: 0
2021-10-03 20:00:43.452686 INFO balkon_bewegungsmelder:    lights:
2021-10-03 20:00:43.456868 INFO balkon_bewegungsmelder:      · light.balkon_wand
2021-10-03 20:00:43.460844 INFO balkon_bewegungsmelder:    dim:
2021-10-03 20:00:43.465178 INFO balkon_bewegungsmelder:      brightness_step_pct: None
2021-10-03 20:00:43.469311 INFO balkon_bewegungsmelder:      seconds_before: 10
2021-10-03 20:00:43.473643 INFO balkon_bewegungsmelder:      method: 1
2021-10-03 20:00:43.477482 INFO balkon_bewegungsmelder:    sensors:
2021-10-03 20:00:43.481770 INFO balkon_bewegungsmelder:      motion:
2021-10-03 20:00:43.485854 INFO balkon_bewegungsmelder:        · binary_sensor.balkon_bewegung
2021-10-03 20:00:43.490202 INFO balkon_bewegungsmelder:      illuminance:
2021-10-03 20:00:43.494878 INFO balkon_bewegungsmelder:        · sensor.balkon_helligkeit
2021-10-03 20:00:43.499080 INFO balkon_bewegungsmelder:    disable_hue_groups: False
2021-10-03 20:00:43.503095 INFO balkon_bewegungsmelder:    only_own_events: False
2021-10-03 20:00:43.507128 INFO balkon_bewegungsmelder:    loglevel: 20
2021-10-03 20:00:43.511136 INFO balkon_bewegungsmelder:    thresholds:
2021-10-03 20:00:43.515430 INFO balkon_bewegungsmelder:      illuminance: 45
2021-10-03 20:00:43.519445 INFO balkon_bewegungsmelder:    disable_switch_entities:
2021-10-03 20:00:43.523626 INFO balkon_bewegungsmelder:      · input_boolean.bewegungsmelder
2021-10-03 20:00:43.527712 INFO balkon_bewegungsmelder:      · input_boolean.bewegungsmelder_aussen
2021-10-03 20:00:43.531723 INFO balkon_bewegungsmelder:    disable_switch_states:
2021-10-03 20:00:43.535777 INFO balkon_bewegungsmelder:      · off
2021-10-03 20:00:43.539811 INFO balkon_bewegungsmelder:  
2021-10-03 20:00:43.629589 WARNING terrasse_bewegungsmelder: ------------------------------------------------------------
2021-10-03 20:00:43.630801 WARNING terrasse_bewegungsmelder: Unexpected error running initialize() for terrasse_bewegungsmelder
2021-10-03 20:00:43.631484 WARNING terrasse_bewegungsmelder: ------------------------------------------------------------
2021-10-03 20:00:43.632738 WARNING terrasse_bewegungsmelder: Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/appdaemon/app_management.py", line 163, in initialize_app
    await init()
  File "/config/appdaemon/apps/ad-automoli/automoli.py", line 403, in initialize
    daytimes = await self.build_daytimes(
  File "/config/appdaemon/apps/ad-automoli/automoli.py", line 1091, in build_daytimes
    if starttime.count(":") == 1:
AttributeError: 'datetime.time' object has no attribute 'count'
2021-10-03 20:00:43.633569 WARNING terrasse_bewegungsmelder: ------------------------------------------------------------
SergioRius commented 1 year ago

Same problem here. Was starting to configure Automoli, but this issue makes it unusable. EDIT: Took the path of creating dummy scenes as a workaround.

overas commented 1 year ago

I also have the same problem. HA Addon AppDaemon Current version: 0.9.3. Automoli v0.11.3 installed from HACS.

System Information

version core-2022.9.1
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.10.5
os_name Linux
os_version 5.15.32-v8
arch aarch64
timezone Europe/Oslo
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 5000 Installed Version | 1.27.1 Stage | running Available Repositories | 1172 Downloaded Repositories | 12
Home Assistant Cloud logged_in | true -- | -- subscription_expiration | October 7, 2022 at 02:00 relayer_connected | true remote_enabled | true remote_connected | true alexa_enabled | false google_enabled | true remote_server | eu-west-2-3.ui.nabu.casa can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Easee EV Charger component_version | 0.9.45 -- | -- reach_easee_cloud | ok connected2stream | true
Home Assistant Supervisor host_os | Home Assistant OS 8.5 -- | -- update_channel | stable supervisor_version | supervisor-2022.08.6 agent_version | 1.2.1 docker_version | 20.10.14 disk_total | 118.3 GB disk_used | 15.7 GB healthy | true supported | true board | rpi4-64 supervisor_api | ok version_api | ok installed_addons | ESPHome (2022.3.1), SSH & Web Terminal (12.0.2), Mosquitto broker (6.1.3), Frigate NVR Proxy (1.3), Home Assistant Google Drive Backup (0.108.4), Z-Wave JS to MQTT (0.46.1), EMHASS (0.2.20), AppDaemon (0.9.3), Studio Code Server (5.3.0)
Dashboards dashboards | 1 -- | -- resources | 2 views | 10 mode | storage
Recorder oldest_recorder_run | September 7, 2022 at 08:20 -- | -- current_recorder_run | September 10, 2022 at 18:00 estimated_db_size | 613.00 MiB database_engine | sqlite database_version | 3.38.5
Spotify api_endpoint_reachable | ok -- | --

Configuration with daytimes in the app.yaml:

bad2etg:
  module: automoli
  class: AutoMoLi
  room: bathroom
  delay: 300
  daytimes:
    - { starttime: "05:30", name: morning, light: 45 }
    - { starttime: "07:30", name: day, light: "80" }
    - { starttime: "20:30", name: evening, light: 100 }
    - { starttime: "sunset+01:00", name: night, light: 0 }
  humidity:
    - sensor.multisensor_bad2etg_humidity
  humidity_threshold: 40
  lights:
    - light.bad2etg_zha_group_0x0005
  motion:
    - binary_sensor.multisensor_bad2etg_home_security_motion_detection

kjokken:
  module: automoli
  class: AutoMoLi
  room: kjokken
  delay: 300
  daytimes:
    - { starttime: "05:30", name: morning, light: 45 }
    - { starttime: "07:30", name: day, light: "80" }
    - { starttime: "20:30", name: evening, light: 100 }
    - { starttime: "sunset+01:00", name: night, light: 0 }
  illuminance: sensor.multisensor_nystue_illuminance
  illuminance_threshold: 80
  lights:
    - light.lys_kjokken
  motion:
    - binary_sensor.multisensor_kjokken_home_security_motion_detection

AD Logs:

2022-09-10 18:52:21.659685 INFO AppDaemon: App 'kjokken' changed
2022-09-10 18:52:21.663745 INFO AppDaemon: Found 8 total apps
2022-09-10 18:52:21.833668 INFO AppDaemon: Terminating kjokken
2022-09-10 18:52:21.840491 INFO AppDaemon: Initializing app kjokken using class AutoMoLi from module automoli
2022-09-10 18:52:22.058957 INFO kjokken:  
2022-09-10 18:52:22.063537 INFO kjokken: 💡 AutoMoLi v0.11.3 · Kjokken
2022-09-10 18:52:22.068591 INFO kjokken:  
2022-09-10 18:52:22.074687 INFO kjokken:    room: Kjokken
2022-09-10 18:52:22.079632 INFO kjokken:    delay: 5:00min ≈ 300sec
2022-09-10 18:52:22.084980 INFO kjokken:    active_daytime: day
2022-09-10 18:52:22.091164 INFO kjokken:    daytimes:
2022-09-10 18:52:22.097250 INFO kjokken:      morning:
2022-09-10 18:52:22.102187 INFO kjokken:        starttime: 05:30:00
2022-09-10 18:52:22.107692 INFO kjokken:        light: 45
2022-09-10 18:52:22.113195 INFO kjokken:      day:
2022-09-10 18:52:22.119157 INFO kjokken:        starttime: 07:30:00
2022-09-10 18:52:22.124486 INFO kjokken:        light: 80
2022-09-10 18:52:22.129956 INFO kjokken:      evening:
2022-09-10 18:52:22.135227 INFO kjokken:        starttime: 20:30:00
2022-09-10 18:52:22.140824 INFO kjokken:        light: 100
2022-09-10 18:52:22.145849 INFO kjokken:      night:
2022-09-10 18:52:22.151522 INFO kjokken:        starttime: 21:07:35
2022-09-10 18:52:22.156629 INFO kjokken:        light: 0
2022-09-10 18:52:22.161796 INFO kjokken:    lights:
2022-09-10 18:52:22.166444 INFO kjokken:      · light.lys_kjokken
2022-09-10 18:52:22.171084 INFO kjokken:    dim:
2022-09-10 18:52:22.176212 INFO kjokken:    sensors:
2022-09-10 18:52:22.181484 INFO kjokken:      motion:
2022-09-10 18:52:22.186771 INFO kjokken:        · binary_sensor.multisensor_kjokken_home_security_motion_detection
2022-09-10 18:52:22.192753 INFO kjokken:      illuminance:
2022-09-10 18:52:22.198192 INFO kjokken:        · sensor.multisensor_nystue_illuminance
2022-09-10 18:52:22.203171 INFO kjokken:    disable_hue_groups: False
2022-09-10 18:52:22.208616 INFO kjokken:    only_own_events: False
2022-09-10 18:52:22.216040 INFO kjokken:    loglevel: 20
2022-09-10 18:52:22.224074 INFO kjokken:    thresholds:
2022-09-10 18:52:22.231608 INFO kjokken:      illuminance: 80
2022-09-10 18:52:22.238425 INFO kjokken:  
2022-09-10 18:52:23.270399 INFO AppDaemon: Reading config
2022-09-10 18:52:23.359768 INFO AppDaemon: /config/appdaemon/apps/ad-automoli/automoli.yaml added or modified
2022-09-10 18:52:23.383853 INFO AppDaemon: Found 8 total apps
2022-09-10 18:57:11.033649 INFO bad2etg:  🛁 no motion in Bathroom since 5min → but 53.0%RH > 40%RH
2022-09-10 18:58:07.916191 INFO AppDaemon: Reading config
2022-09-10 18:58:07.976026 INFO AppDaemon: /config/appdaemon/apps/ad-automoli/automoli.yaml added or modified
2022-09-10 18:58:07.994753 INFO AppDaemon: App 'bad2etg' changed
2022-09-10 18:58:08.001588 INFO AppDaemon: Found 8 total apps
2022-09-10 18:58:08.176233 INFO AppDaemon: Terminating bad2etg
2022-09-10 18:58:08.183394 INFO AppDaemon: Initializing app bad2etg using class AutoMoLi from module automoli
2022-09-10 18:58:08.404965 INFO bad2etg: Previous message repeated 1 times
2022-09-10 18:58:08.407838 INFO bad2etg:  
2022-09-10 18:58:08.414187 INFO bad2etg: 💡 AutoMoLi v0.11.3 · Bathroom
2022-09-10 18:58:08.420333 INFO bad2etg:  
2022-09-10 18:58:08.427398 INFO bad2etg:    room: Bathroom
2022-09-10 18:58:08.433209 INFO bad2etg:    delay: 5:00min ≈ 300sec
2022-09-10 18:58:08.439022 INFO bad2etg:    active_daytime: day
2022-09-10 18:58:08.444604 INFO bad2etg:    daytimes:
2022-09-10 18:58:08.450757 INFO bad2etg:      morning:
2022-09-10 18:58:08.456756 INFO bad2etg:        starttime: 05:30:00
2022-09-10 18:58:08.462471 INFO bad2etg:        light: 25
2022-09-10 18:58:08.470647 INFO bad2etg:      day:
2022-09-10 18:58:08.476387 INFO bad2etg:        starttime: 07:30:00
2022-09-10 18:58:08.482036 INFO bad2etg:        light: 100
2022-09-10 18:58:08.487697 INFO bad2etg:      evening:
2022-09-10 18:58:08.498977 INFO bad2etg:        starttime: 20:30:00
2022-09-10 18:58:08.507438 INFO bad2etg:        light: 90
2022-09-10 18:58:08.514743 INFO bad2etg:      night:
2022-09-10 18:58:08.521793 INFO bad2etg:        starttime: 22:30:00
2022-09-10 18:58:08.527006 INFO bad2etg:        light: 0
2022-09-10 18:58:08.532363 INFO bad2etg:    lights:
2022-09-10 18:58:08.537663 INFO bad2etg:      · light.bad2etg_zha_group_0x0005
2022-09-10 18:58:08.542164 INFO bad2etg:    dim:
2022-09-10 18:58:08.546677 INFO bad2etg:    sensors:
2022-09-10 18:58:08.551658 INFO bad2etg:      motion:
2022-09-10 18:58:08.558671 INFO bad2etg:        · binary_sensor.multisensor_bad2etg_home_security_motion_detection
2022-09-10 18:58:08.568872 INFO bad2etg:      humidity:
2022-09-10 18:58:08.574343 INFO bad2etg:        · sensor.multisensor_bad2etg_humidity
2022-09-10 18:58:08.579248 INFO bad2etg:    disable_hue_groups: False
2022-09-10 18:58:08.583869 INFO bad2etg:    only_own_events: False
2022-09-10 18:58:08.588426 INFO bad2etg:    loglevel: 20
2022-09-10 18:58:08.592558 INFO bad2etg:    thresholds:
2022-09-10 18:58:08.597021 INFO bad2etg:      humidity: 40
2022-09-10 18:58:08.601034 INFO bad2etg:  

Configuration without daytimes in the app.yaml:

bad2etg:
  module: automoli
  class: AutoMoLi
  room: bathroom
  delay: 300
  humidity:
    - sensor.multisensor_bad2etg_humidity
  humidity_threshold: 40
  lights:
    - light.bad2etg_zha_group_0x0005
  motion:
    - binary_sensor.multisensor_bad2etg_home_security_motion_detection

kjokken:
  module: automoli
  class: AutoMoLi
  room: kjokken
  delay: 300
  illuminance: sensor.multisensor_nystue_illuminance
  illuminance_threshold: 80
  lights:
    - light.lys_kjokken
  motion:
    - binary_sensor.multisensor_kjokken_home_security_motion_detection

AD Logs:

2022-09-10 18:58:13.078529 INFO AppDaemon: Reading config
2022-09-10 18:58:13.129655 INFO AppDaemon: /config/appdaemon/apps/ad-automoli/automoli.yaml added or modified
2022-09-10 18:58:13.159161 INFO AppDaemon: App 'kjokken' changed
2022-09-10 18:58:13.165647 INFO AppDaemon: Found 8 total apps
2022-09-10 18:58:13.341637 INFO AppDaemon: Terminating kjokken
2022-09-10 18:58:13.345319 INFO AppDaemon: Initializing app kjokken using class AutoMoLi from module automoli
2022-09-10 18:58:13.575448 WARNING kjokken: ------------------------------------------------------------
2022-09-10 18:58:13.576895 WARNING kjokken: Unexpected error running initialize() for kjokken
2022-09-10 18:58:13.578207 WARNING kjokken: ------------------------------------------------------------
2022-09-10 18:58:13.580026 WARNING kjokken: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/appdaemon/app_management.py", line 163, in initialize_app
    await init()
  File "/config/appdaemon/apps/ad-automoli/automoli.py", line 402, in initialize
    daytimes = await self.build_daytimes(
  File "/config/appdaemon/apps/ad-automoli/automoli.py", line 1088, in build_daytimes
    if starttime.count(":") == 1:
AttributeError: 'datetime.time' object has no attribute 'count'
2022-09-10 18:58:13.580870 WARNING kjokken: ------------------------------------------------------------
2022-09-10 19:03:09.031119 INFO bad2etg:  🛁 no motion in Bathroom since 5min → but 53.0%RH > 40%RH