Use new switch.on_state
This commit is contained in:
@@ -1526,20 +1526,18 @@ switch:
|
||||
optimistic: true
|
||||
internal: false
|
||||
entity_category: config
|
||||
on_turn_on:
|
||||
on_state:
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_pending_restart
|
||||
state: true
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) |= 0x01; // Set bit 0
|
||||
on_turn_off:
|
||||
- if:
|
||||
condition:
|
||||
- lambda: return x; // Turned on?
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_pending_restart
|
||||
state: true
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) &= ~0x01; // Clear bit 0
|
||||
- lambda: id(relay_switches_packed) |= 0x01; // Set bit 0
|
||||
else:
|
||||
- lambda: id(relay_switches_packed) &= ~0x01; // Clear bit 0
|
||||
|
||||
- id: sw_relay_1
|
||||
name: Relay 1
|
||||
@@ -1547,103 +1545,99 @@ switch:
|
||||
platform: output
|
||||
restore_mode: ${RELAYS_SWITCH_RESTORE_MODE}
|
||||
internal: true
|
||||
on_turn_on:
|
||||
on_state:
|
||||
then:
|
||||
- script.execute: show_relay_status
|
||||
on_turn_on:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
- light.is_off: light_output_1
|
||||
then:
|
||||
light.turn_on: light_output_1
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) |= 0x02; // Set bit 1
|
||||
- lambda: id(relay_switches_packed) |= 0x02; // Set bit 1
|
||||
on_turn_off:
|
||||
then:
|
||||
- script.execute: show_relay_status
|
||||
- if:
|
||||
condition:
|
||||
- light.is_on: light_output_1
|
||||
then:
|
||||
- light.turn_off: light_output_1
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) &= ~0x02; // Clear bit 1
|
||||
- lambda: id(relay_switches_packed) &= ~0x02; // Clear bit 1
|
||||
- id: sw_relay_2
|
||||
name: Relay 2
|
||||
output: output_relay_2
|
||||
platform: output
|
||||
restore_mode: ${RELAYS_SWITCH_RESTORE_MODE}
|
||||
internal: true
|
||||
on_turn_on:
|
||||
on_state:
|
||||
then:
|
||||
- script.execute: show_relay_status
|
||||
on_turn_on:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
- light.is_off: light_output_2
|
||||
then:
|
||||
light.turn_on: light_output_2
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) |= 0x04; // Set bit 2
|
||||
- lambda: id(relay_switches_packed) |= 0x04; // Set bit 2
|
||||
on_turn_off:
|
||||
then:
|
||||
- script.execute: show_relay_status
|
||||
- if:
|
||||
condition:
|
||||
- light.is_on: light_output_2
|
||||
then:
|
||||
- light.turn_off: light_output_2
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) &= ~0x04; // Clear bit 2
|
||||
- lambda: id(relay_switches_packed) &= ~0x04; // Clear bit 2
|
||||
- id: sw_relay_3
|
||||
name: Relay 3
|
||||
output: output_relay_3
|
||||
platform: output
|
||||
restore_mode: ${RELAYS_SWITCH_RESTORE_MODE}
|
||||
internal: true
|
||||
on_turn_on:
|
||||
on_state:
|
||||
then:
|
||||
- script.execute: show_relay_status
|
||||
on_turn_on:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
- light.is_off: light_output_3
|
||||
then:
|
||||
- light.turn_on: light_output_3
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) |= 0x08; // Set bit 3
|
||||
- lambda: id(relay_switches_packed) |= 0x08; // Set bit 3
|
||||
on_turn_off:
|
||||
then:
|
||||
- script.execute: show_relay_status
|
||||
- if:
|
||||
condition:
|
||||
- light.is_on: light_output_3
|
||||
then:
|
||||
- light.turn_off: light_output_3
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) &= ~0x08; // Clear bit 3
|
||||
- lambda: id(relay_switches_packed) &= ~0x08; // Clear bit 3
|
||||
- id: sw_relay_4
|
||||
name: Relay 4
|
||||
output: output_relay_4
|
||||
platform: output
|
||||
restore_mode: ${RELAYS_SWITCH_RESTORE_MODE}
|
||||
internal: true
|
||||
on_turn_on:
|
||||
on_state:
|
||||
then:
|
||||
- script.execute: show_relay_status
|
||||
on_turn_on:
|
||||
then:
|
||||
- if:
|
||||
condition:
|
||||
- light.is_off: light_output_4
|
||||
then:
|
||||
- light.turn_on: light_output_4
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) |= 0x10; // Set bit 4
|
||||
- lambda: id(relay_switches_packed) |= 0x10; // Set bit 4
|
||||
on_turn_off:
|
||||
then:
|
||||
- script.execute: show_relay_status
|
||||
- if:
|
||||
condition:
|
||||
- light.is_on: light_output_4
|
||||
then:
|
||||
- light.turn_off: light_output_4
|
||||
- lambda: |-
|
||||
id(relay_switches_packed) &= ~0x10; // Clear bit 4
|
||||
- lambda: id(relay_switches_packed) &= ~0x10; // Clear bit 4
|
||||
|
||||
...
|
||||
|
||||
@@ -151,20 +151,17 @@ switch:
|
||||
pin: GPIO21
|
||||
restore_mode: ALWAYS_OFF
|
||||
internal: true
|
||||
on_turn_on:
|
||||
on_state:
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_vibrating
|
||||
state: ON # yamllint disable-line rule:truthy
|
||||
state: !lambda return x;
|
||||
on_turn_on:
|
||||
then:
|
||||
- delay: ${vibration_max_duration}
|
||||
- if:
|
||||
condition:
|
||||
switch.is_on: sw_vibration_motor
|
||||
then:
|
||||
- switch.turn_off: sw_vibration_motor
|
||||
on_turn_off:
|
||||
then:
|
||||
- binary_sensor.template.publish:
|
||||
id: bs_vibrating
|
||||
state: OFF # yamllint disable-line rule:truthy
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user