Towel rails logic
The towel rails can be scheduled (scheduler) or turned ON and OFF by the measurement of excess solar power. During the day is the incoming solar is greater than 800 watts for 1 minute then all of the rails are turned on directly, using the input_boolean turn_on command. There are two boolean's per rail, one for solar and one for the scheduler.
alias: Heated rails on description: "" trigger: - platform: numeric_state entity_id: sensor.grid_feed_in above: "800" for: "00:01:00" condition: [] action: - service: input_boolean.turn_on target: entity_id: - input_boolean.master_bath_towel_solar - input_boolean.rachel_bathroom_towel_solar - input_boolean.girls_towel_rail_solar - input_boolean.laundry_towel_solar data: {} mode: single
The solar system does not turn off rails if they are scheduled ON, instead it just turns of the solar input_booleans for all rails
alias: Heated rails OFF description: "" trigger: - platform: numeric_state entity_id: sensor.meter_power_a above: "-100" for: "00:00:30" condition: [] action: - service: input_boolean.turn_off target: entity_id: - input_boolean.master_bath_towel_solar - input_boolean.rachel_bathroom_towel_solar - input_boolean.girls_towel_rail_solar - input_boolean.laundry_towel_solar data: {} mode: single
Finally boolean logic is applied. Using an OR gate, if either solar or scheduler wants the rails on they are turned ON. There is separate ON and OFF logic for each towel rail:
alias: Girls rail ON description: "" trigger: - platform: state entity_id: - input_boolean.girls_towel_rail - input_boolean.girls_towel_rail_solar condition: - condition: or conditions: - condition: state entity_id: input_boolean.girls_towel_rail state: "on" - condition: state entity_id: input_boolean.girls_towel_rail_solar state: "on" action: - service: switch.turn_on data: {} target: entity_id: switch.girls_towel_rail mode: single
and Using an AND gate, if both solar or scheduler wants the rails off they are turned OFF.
alias: Girls rail OFF description: "" trigger: - platform: state entity_id: - input_boolean.girls_towel_rail - input_boolean.girls_towel_rail_solar condition: - condition: and conditions: - condition: state entity_id: input_boolean.girls_towel_rail state: "off" - condition: state entity_id: input_boolean.girls_towel_rail_solar state: "off" action: - service: switch.turn_off data: {} target: entity_id: switch.girls_towel_rail mode: single