OK, after several attempts i think i finally got it. I am using a Sonoff Basic connected to a normal light switch and the bulb is a Sonoff B1. Both flashed with tasmota and connected via MQTT to home assistant. I use this light in our hallway. During the day it is used as a normal white light, during the night it is used as night light utilising the B1 colors, trigged by two binary door sensors and a two-way wall switch,
(config.yaml)
- platform: mqtt
name: "hallway lamp"
command_topic: "cmnd/hallway_lamp/power"
state_topic: "stat/hallway_lamp/POWER"
rgb_state_topic: "stat/hallway_lamp/color"
rgb_command_topic: "cmnd/hallway_lamp/color"
brightness_state_topic: "stat/hallway_lamp/dimmer"
brightness_command_topic: "cmnd/hallway_lamp/dimmer"
color_temp_state_topic: "stat/hallway_lamp/CT"
color_temp_command_topic: "cmnd/hallway_lamp/CT"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: true
(Automations.yaml)
alias: Hallway light during the day
trigger:
- entity_id: light.hallway_light,light.hallway_lamp
from: 'off'
platform: state
to: 'on'
condition:
- after: 06:30
before: '21:00'
condition: time
action:
- data:
entity_id: light.hallway_light,light.hallway_lamp
kelvin: '4000'
service: light.turn_on
alias: Hallway sensor Automation 2
trigger:
- entity_id: binary_sensor.hallway_door
from: 'off'
platform: state
to: 'on'
condition:
- after: '21:00'
before: 06:30
condition: time
action:
- data:
color_name: purple
entity_id: light.hallway_light,light.hallway_lamp
service: light.turn_on
alias: Toilet sensor
trigger:
- entity_id: binary_sensor.Toilet_door
from: 'Off'
platform: state
to: 'On'
condition:
- after: '21:00'
before: 06:30
condition: time
action:
- data:
color_name: green
entity_id: light.hallway_light,light.hallway_lamp
service: light.turn_on
if there is any problem with the code please let me know. Thanks for your help PTRSNJA.