Want to have my Side bed lights come on base on who in bed
Shopping List
https://www.itead.cc/sonoff-wifi-wireless-switch.html
Flash the Sonoff with Tasmota
wire one to the RX and the other to TX of the sonoff
set the the SwitchMode 2
Turn on the SwitchTopic 1
Check to see if I stand on then do I see any thing
place under the mattress NOT to close to the side and about where you bum is ok
binarysensor.yaml
#=======================================================================
#
#=======================================================================
- platform: mqtt
name: "In bed her side"
state_topic: "cmnd/bed/POWER2"
qos: 1
retain: true
device_class: motion
#=======================================================================
#
#=======================================================================
- platform: mqtt
name: "In bed his side"
state_topic: "cmnd/bed/POWER3"
qos: 1
retain: true
device_class: motion
#=======================================================================
#
#=======================================================================
light.yaml
#=======================================================================
#
#=======================================================================
- platform: mqtt
entity_id: "Bedroom"
name: "Master Bedroom"
state_topic: "stat/MasterLight/POWER"
command_topic: "cmnd/MasterLight/POWER1"
payload_on: "ON"
payload_off: "OFF"
optimistic: false
qos: 0
retain: true
#=======================================================================
#
#=======================================================================
- platform: mqtt
name: "Her Side"
state_topic: "stat/herSide/POWER"
command_topic: "cmnd/herSide/POWER"
payload_on: "ON"
payload_off: "OFF"
optimistic: false
qos: 0
retain: true
#=======================================================================
#
#=======================================================================
- platform: mqtt
name: "His Side"
state_topic: "stat/hisSide/POWER"
command_topic: "cmnd/hisSide/POWER"
payload_on: "ON"
payload_off: "OFF"
optimistic: false
qos: 0
retain: true
#=======================================================================
#
#=======================================================================
also need to see when we are pressing the HOLD
so in sensor.yaml
#=======================================================================
- platform: mqtt
name: "herSide Light"
state_topic: "cmnd/herSide/POWER1"
qos: 1
expire_after: "1"
retain: true
#=======================================================================
- platform: mqtt
name: "hisSide Light"
state_topic: "cmnd/hisSide/POWER1"
qos: 1
expire_after: "1"
retain: true
#=======================================================================
- platform: mqtt
name: "master Light"
state_topic: "cmnd/MasterLight/POWER1"
qos: 1
expire_after: "1"
retain: true
note the “expire_after:” forget what happen after 1 sec
now the FUN part
#=======================================================================
#
#=======================================================================
- id: 'hold Master light off off'
alias: hold Master light off off
initial_state: true
trigger:
- entity_id: sensor.master_light
platform: state
to: 'HOLD'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.in_bed_his_side
state: 'off'
- condition: state
entity_id: binary_sensor.in_bed_her_side
state: 'off'
action:
- data:
entity_id: light.her_side , light.his_side
service: light.toggle
- data:
entity_id: input_boolean.going_to_bed
service: input_boolean.turn_on
#=======================================================================
#
#=======================================================================
- id: 'hold Master light on off'
alias: hold Master light on off
initial_state: true
trigger:
- entity_id: sensor.master_light
platform: state
to: 'HOLD'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.in_bed_his_side
state: 'on'
- condition: state
entity_id: binary_sensor.in_bed_her_side
state: 'off'
action:
- data:
entity_id: light.her_side
service: light.toggle
- data:
entity_id: input_boolean.going_to_bed
service: input_boolean.turn_on
#=======================================================================
#
#=======================================================================
- id: 'hold Master light off on'
alias: hold Master light off on
initial_state: true
trigger:
- entity_id: sensor.master_light
platform: state
to: 'HOLD'
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.in_bed_his_side
state: 'off'
- condition: state
entity_id: binary_sensor.in_bed_her_side
state: 'on'
action:
- data:
entity_id: light.his_side
service: light.toggle
- data:
entity_id: input_boolean.going_to_bed
service: input_boolean.turn_on
the lovelace look
its card
cards:
- entities:
- entity: binary_sensor.in_bed_her_side
icon: 'mdi:bed-empty'
name: Debbie
- entity: binary_sensor.in_bed_his_side
icon: 'mdi:bed-empty'
name: StePhan
title: Master Bedroom
type: glance
- cards:
- entity: light.her_side
tap_action:
action: toggle
type: entity-button
- entity: light.master_bedroom
hold_action:
action: toggle
icon: 'mdi:ceiling-light'
name: light
tap_action:
action: toggle
type: entity-button
- entity: light.his_side
tap_action:
action: toggle
type: entity-button
type: horizontal-stack
- entities:
- entity: binary_sensor.in_bed_his_side
name: StePhan
- entity: binary_sensor.in_bed_her_side
name: Debbie
hours_to_show: 48
title: ''
type: history-graph
type: 'custom:vertical-stack-in-card'