jseidl / hass-magic_areas

Areas with batteries included for Home Assistant
MIT License
192 stars 27 forks source link

2.0.1: Lights doesn't turn on when Area goes active #84

Closed TheArcturian closed 3 years ago

TheArcturian commented 3 years ago

This might be a user error. 3 of my areas does not turn the lights on when the Area goes active (detected). They get active mainly by motion sensor or media player. The lights are defined automatically in the areas and are a mix of switches defined as light entities and a few light devices (Nanoleaf, Aeotec Dimmer). I have also added the lights manually through the "Include entities to this area", but it still doesn't help.

3 other rooms that just have a door sensor with a Ikea lightbulb in the ceiling works fine. I have configured all rooms pretty much the same.

jseidl commented 3 years ago

In those areas, can you take a look at the area's binary sensor and see the if state the attribute automatic_lights says enabled?

Can you post the whole attribute list for the offending areas binary_sensors?

TheArcturian commented 3 years ago

AreaScreenshot

TheArcturian commented 3 years ago

Here is a room that works fine, for comparison: AreaScreenshot2

jseidl commented 3 years ago

That's weird, looks alright. Does Jupiter turns them off when the area is clear?

jseidl commented 3 years ago

Also, can you set the component debug logging?

logger:
    default: warning
    logs:
        custom_components.magic_areas.binary_sensor: debug
TheArcturian commented 3 years ago

It seems like Automatic lights is "disabled" on the troubled areas, but only when not in night mode. How can I set Automatic lights to Enabled?

jseidl commented 3 years ago

Automatic lights is disabled at day (when not night mode). It will be enabled if it's night. Another status can be sleep if sleep_entity is at sleep_state. This will triger sleep_lights instead of main_lights (all if not defined).

TheArcturian commented 3 years ago

Thanks for the clarification. However, I still have the same problem with 3 of my 6 areas I'm using currently. The area is detected, but no lights is turned on. The only change in HA is upgrading to Magic Areas 2.0.x.

This is from the log:

2021-02-01 10:49:05 DEBUG (MainThread) [custom_components.magic_areas.binary_sensor] Creating aggregate sensor for device_class 'motion' with 2 entities (jupiter) 2021-02-01 10:49:05 DEBUG (MainThread) [custom_components.magic_areas.binary_sensor] Creating aggregate sensor for device_class 'plug' with 2 entities (jupiter) 2021-02-01 10:49:05 WARNING (MainThread) [custom_components.magic_areas.sensor] Entity sensor.jupiter_monitor_current does not have device_class defined 2021-02-01 10:49:05 WARNING (MainThread) [custom_components.magic_areas.sensor] Entity sensor.jupiter_badekar_voltage does not have device_class defined 2021-02-01 10:49:05 WARNING (MainThread) [custom_components.magic_areas.sensor] Entity sensor.master_iphone_storage does not have device_class defined 2021-02-01 10:49:05 WARNING (MainThread) [custom_components.magic_areas.sensor] Entity sensor.aeon_network_0_speed does not have device_class defined 2021-02-01 10:49:05 WARNING (MainThread) [custom_components.magic_areas.sensor] Entity sensor.master_iphone_battery_state does not have unit_of_measurement defined 2021-02-01 10:49:05 WARNING (MainThread) [custom_components.magic_areas.sensor] Entity sensor.master_ipad_connection_type does not have device_class defined 2021-02-01 10:49:05 WARNING (MainThread) [custom_components.magic_areas.sensor] Entity sensor.aeon_storage_d_label does not have device_class defined 2021-02-01 10:49:05 WARNING (MainThread) [custom_components.magic_areas.sensor] Entity sensor.jupiter_vegglamper_power does not have device_class defined 2021-02-01 10:49:05 WARNING (MainThread) [custom_components.magic_areas.sensor] Entity sensor.master_iphone_ssid does not have device_class defined

And this list goes on for a loooong while. Here is a few ERROR or DEBUG log entries:

2021-02-01 10:49:06 ERROR (SyncWorker_3) [homeassistant.components.homekit.util] media_player.area_aware_media_player does not support any media_player features 2021-02-01 10:49:06 DEBUG (MainThread) [custom_components.magic_areas.binary_sensor] Creating aggregate sensor for device_class 'motion' with 5 entities (global) 2021-02-01 10:49:06 DEBUG (MainThread) [custom_components.magic_areas.binary_sensor] Creating aggregate sensor for device_class 'safety' with 6 entities (global) 2021-02-01 10:49:06 DEBUG (MainThread) [custom_components.magic_areas.binary_sensor] Creating aggregate sensor for device_class 'door' with 3 entities (global) 2021-02-01 10:49:06 DEBUG (MainThread) [custom_components.magic_areas.binary_sensor] Creating aggregate sensor for device_class 'plug' with 3 entities (global) 2021-02-01 10:49:06 DEBUG (MainThread) [custom_components.magic_areas.binary_sensor] Creating aggregate sensor for device_class 'moisture' with 2 entities (global) 2021-02-01 10:49:06 DEBUG (MainThread) [custom_components.magic_areas.binary_sensor] Creating helth sensor for area (global)

TheArcturian commented 3 years ago

In one of the functional areas, I added a light from a problem area. The light turned on when activating the ok area. None of my functional areas have a night or sleep mode binary sensor set.

Because of a bug in the GUI i can't remove the Night binary sensor from "Entity used to track area night state". I select the first choise in the list, which is blank. Clicking Submit and gets a successful feedback. Going back into the setting, the binary sensor is still there. I presume the same problem goes for the "sleep state" setting.

TheArcturian commented 3 years ago

Automatic lights is disabled at day (when not night mode). It will be enabled if it's night. Another status can be sleep if sleep_entity is at sleep_state. This will triger sleep_lights instead of main_lights (all if not defined).

Is "Automatic lights" only referring to the "Sleep lights" still? This will definitively confuse new users.

Logically what is the difference of the words "Night" and "Sleep"? Would a better and less confusing naming be "Disable" and "Sleep" like in 1.x?

If I set my binary_sensor.night_mode to Off (which automatically is set between 08:00 and 24:00), I would expect the lights for that area to go on as normal during that window. Logically it doesn't make sense that I need to set Night to true to get lights working during daytime. Is it really meant to be like this or is it a logically bug?

jseidl commented 3 years ago

Is "Automatic lights" only referring to the "Sleep lights" still? This will definitively confuse new users.

Automatic lights will only turn on when the area is in night mode. The move from disable was to support other features to benefit from the night and sleep state.

Logically what is the difference of the words "Night" and "Sleep"?

Night defines if lights should turn on at all, sleep allows you to define ANOTHER (sleep_lights) set of lights to turn on when both at night and sleep.

to get lights working during daytime.

To get lights working at any time of day, you shall leave night_entity blank. There's a bug currently where you cannot clear the dropdown after you set. I'm working on this. Current workaround is to delete the specific area from the integrations UI and restart (it will be recreated with default options)

Hope this diagram helps for now: image

TheArcturian commented 3 years ago

A example scenario: I have an area called Jupiter that should not turn on lights during nighttime. I have another area called Mars that have a sleep light.

For the area Mars; Is the only way to reach "Is area in sleep state" to have a separate "night_entity" that is always On so "Is area in night state" turns out to be Yes?

Because if I use just one night_entity (binary sensor) and that one turns off at 23:00 it will function fine for the area Jupiter, but it will never reach "Is area in sleep state" for area Mars.

So do we need 3 binary sensors for this scenario?

  1. A binary_sensor.night_mode that is TRUE (on) only during daytime until 23:00.
  2. A binary_sensor.always_night_mode that is ALWAYS TRUE so it is possible to check sleep state.
  3. A binary_sensor.sleep_mode that is the reverse of the first one so that it is TRUE during nighttime.
jseidl commented 3 years ago

What is the behavior you want from those rooms? e.g.:

$AT_NIGHT = 18h-23h $AT_SLEEP = 24h-6h

  1. I want Jupiter to never turn on any lights.
  2. I want Mars to turn on some nights $AT_NIGHT but only my night light at $AT_SLEEP
TheArcturian commented 3 years ago

I need to let you know my pattern for my house first. In my house, the windows dont let enough light in and the illuminance outside is not so bright during wintertime (in my rooms, the lux is only 5 - 50 at 11 am these days). That means I need lights in all rooms from early morning throughout the day until we go to bed. So typically from 08:00 until 24:00. In that periode the lights should always turn on for all rooms.

So: $AT_NIGHT = 08h-24h $AT_SLEEP = 24h-8h

  1. I want Jupiter to turn on all lights from 08:00 to 24:00. Rest of the time it can be pitch black.
  2. I want Mars to turn on all lights from 08:00 to 24:00 and after that only my sleep light at $AT_SLEEP

So logically, for me, using Night = true from 08 - 24 is not so logically, but I can live with that. What is a bit excessive is that it seems like I need 3 binary sensors for rooms that I want sleep lights. If you read my previous post, does my question about 3 binary sensors make more sense now?

jseidl commented 3 years ago

I did not get what the 2nd sensor would do.

From your scenario, I'd use binary_sensor.night_mode for all rooms and set binary_sensor.sleep_mode and the sleep_lights you want for Mars (and other rooms that you want to use sleep lights) and that should be it, if I understood you correctly.

This will have all rooms turn no lights from 00:01 till 7:59 (pitch black), then you'll have lights come in during your night time and have your sleep lights.

TheArcturian commented 3 years ago

When Night = false, it doesn't seem like Sleep = True will work. According to your diagram, if Night = false (as it is after midnight) it will not go to check "Is area in sleep state".

That means I can't use the same night_mode entity on rooms using sleep lights as rooms that should have no light after midnight.

jseidl commented 3 years ago

Ahhh gotcha. So for case 2, you'd set your night_entity to be on forever and have your sleep_entity only be on from 1:00AM-7:59AM.

In that case during 8-24 it would turn on all lights but only sleep lights in other times.