I have been reworking my automation’s and my wife asked for something that I think is a good idea. We have a mudroom which I have two Hue lights in and a Neo Coolcam motion sensor. I have an automation that does the following:
When motion is detected, turn on the lights in this room if:
a) Either one of us is home
b) It’s an hour before sunset or an hour before sunrise
So I wrote this automation, it seems to work well:
- alias: Mudroom-Motion
trigger:
- platform: state
entity_id: binary_sensor.neo_coolcam_battery_powered_pir_sensor_mudroom
from: 'off'
to: 'on'
condition:
- condition: state
entity_id: light.mudroom
state: 'off'
- condition: or
conditions:
- condition: state
entity_id: input_select.chris_status_dropdown
state: 'Home'
- condition: state
entity_id: input_select.val_status_dropdown
state: 'Home'
- condition: or
conditions:
- condition: sun
after: sunset
after_offset: "-1:00:00"
- condition: sun
before: sunrise
before_offset: "1:00:00"
action:
- service: homeassistant.turn_on
entity_id: light.mudroom
So my wife asked that if the time is midnight to 1 hour before sunrise that the brightness of these lights be 50% of normal brightness (reason being, she might get up at 2AM to go for a smoke and she would use this door to go outside to do so and doesn’t want super-bright light to flood the area.) I think that this is a really good idea (I wouldn’t see the light but that doesn’t make it a bad idea as when the door opens, the light would flood out into the porch) but I’m stuck how to integrate such a notion into the existing automation above.
So my question is, how do I do this? I was hoping for some kind of variable assignment (which I’ve been crawling the forum for an answer) with the basic idea of having an additional condition such as (pseudo-code):
Which would then be applied to the action. Anyone have any ideas how I can accomplish this or do I need to write a separate automation and/or script to do this?
But it’s generating an error in config-check, can’t see what the issue is per se:
2018-02-16 20:31:40 ERROR (MainThread) [homeassistant.config] Invalid config for [automation]: Entity ID {% '{{ if now().hour >= 23 and now().hour <= 6 }}' %}
scene.nightlight
{% else %}
scene.bright
{% endif %} is an invalid entity id for dictionary value @ data['action'][0]['entity_id']. Got None
expected a dictionary for dictionary value @ data['action'][0]['data_template']. Got None. (See /home/hass/.homeassistant/configuration.yaml, line 126). Please check the docs at https://home-assistant.io/components/automation/
I just realized that my scenes only target the livingroom lights as they’re ambient bulbs. Normally we’ve been using brightness (vs scene) for all other lights. I may have to duplicate the scene for mudroom I guess.
EDIT: I should note that my living lights were indeed changing to nightlight / bright as I altered the automation time frame to test This is the solution, thank you my friend