Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not work when there is only a single daytime #112

Open
Ramblurr opened this issue Oct 11, 2022 · 1 comment
Open

Does not work when there is only a single daytime #112

Ramblurr opened this issue Oct 11, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@Ramblurr
Copy link

😩 Describe the issue/bug

Does not work when there is only a single daytime.

πŸ˜’ Expected behavior

It should work with only a single daytime

πŸŽ›οΈ Configuration

---
toilet:
  module: automoli
  class: AutoMoLi
  room: toilet
  debug_log: true
  motion:
    - binary_sensor.wc_motion_sensor_occupancy
  delay: 5
  motion_state_on: "on"
  motion_state_off: "off"
  lights:
    - switch.toilet
  daytimes:
    - { name: alwayson, starttime: "00:00", light: 100 }

🧠 System

  • AppDaemon: [e.g. 4.0.5]
    • running mode: [e.g. virtualenv, hassio-plugin, docker]
  • Home-Assistant: [e.g. 0.118.3, 0.119.0b0]
    • running mode: [e.g. virtualenv, hassio, docker]
  • Python: [e.g. 3.8.6, 3.9]

πŸ—’οΈ Logs

When the app is loaded

2022-10-11 20:14:11.532271 WARNING toilet: 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/automoli/automoli.py", line 448, in initialize "active_daytime": self.active_daytime, AttributeError: 'AutoMoLi' object has no attribute 'active_daytime' 

when the motion sensor is triggered:

2022-10-11 20:14:14.997915 WARNING toilet: Traceback (most recent call last): File "/usr/lib/python3.10/site-packages/appdaemon/threading.py", line 826, in async_worker await funcref( File "/config/appdaemon/apps/automoli/automoli.py", line 568, in motion_detected await self.motion_event("state_changed_detection", data, kwargs) File "/config/appdaemon/apps/automoli/automoli.py", line 597, in motion_event await self.lights_on() File "/config/appdaemon/apps/automoli/automoli.py", line 940, in lights_on raise ValueError( ValueError: invalid brightness/scene: None in <adutils.Room object at 0x7f98b8f27070>  

🧁 Additional context

This happens because the self.active_daytime is never set so an exception occurs on line 448.

self.active_daytime is not set because the code for it expects there to be at least two daytimes:

            # check if this daytime should ne active now
            if await self.now_is_between(str(dt_start), str(next_dt_start)):
                await self.switch_daytime(dict(daytime=daytime, initial=True))
                self.active_daytime = daytime.get("daytime")

Also this line should have self.room.name for a useful log output

@mycanaletto
Copy link

mycanaletto commented Nov 5, 2022

Doesn't work either if you don't put the daytime: line, which seems optional...

@evildad evildad added the bug Something isn't working label Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants