Ok, in my opinion, you should change your MQTT configuration to:
mqtt:
- binary_sensor:
- unique_id: sip_front_t0_s01
default_entity_id: binary_sensor.front_t0_s01
name: Front T0 S01
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('Front T0 S01', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_courtyard_t0_s02
default_entity_id: binary_sensor.courtyard_t0_s02
name: Courtyard T0 S02
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('Courtyard T0 S02', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_north_t0_s03
default_entity_id: binary_sensor.north_t0_s03
name: North T0 S03
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('North T0 S03', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_south_of_steps_t1_s04
default_entity_id: binary_sensor.south_of_steps_t1_s04
name: south of steps T1 S04
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('south of steps T1 S04', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_no_valve_t1_s05
default_entity_id: binary_sensor.no_valve_t1_s05
name: (no valve) T1 S05
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('(no valve) T1 S05', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t2_s06
default_entity_id: binary_sensor.t2_s06
name: T2 S06
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T2 S06', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t2_s07
default_entity_id: binary_sensor.t2_s07
name: T2 S07
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T2 S07', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t3_s08
default_entity_id: binary_sensor.t3_s08
name: T3 S08
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T3 S08', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t3_s09
default_entity_id: binary_sensor.t3_s09
name: T3 S09
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T3 S09', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_no_valve_t4_s10
default_entity_id: binary_sensor.no_valve_t4_s10
name: (no valve) T4 S10
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('(no valve) T4 S10', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_south_hill_t4_s11
default_entity_id: binary_sensor.south_hill_t4_s11
name: South Hill T4 S11
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('South Hill T4 S11', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_se_hill_t4_s12
default_entity_id: binary_sensor.se_hill_t4_s12
name: SE Hill T4 S12
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('SE Hill T4 S12', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t5_s13
default_entity_id: binary_sensor.t5_s13
name: T5 S13
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T5 S13', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t5_s14
default_entity_id: binary_sensor.t5_s14
name: T5 S14
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T5 S14', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_se_hill_t6_s15
default_entity_id: binary_sensor.se_hill_t6_s15
name: SE Hill T6 S15
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('SE Hill T6 S15', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t6_s16
default_entity_id: binary_sensor.t6_s16
name: T6 S16
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T6 S16', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t7_s17
default_entity_id: binary_sensor.t7_s17
name: T7 S17
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T7 S17', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t8_s18
default_entity_id: binary_sensor.t8_s18
name: T8 S18
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T8 S18', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_t9_s19
default_entity_id: binary_sensor.t9_s19
name: T9 S19
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('T9 S19', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_jim_s_lower_t9_s20
default_entity_id: binary_sensor.jim_s_lower_t9_s20
name: Jim's lower T9 S20
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('Jim's lower T9 S20', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_jim_s_upper_t9_s21
default_entity_id: binary_sensor.jim_s_upper_t9_s21
name: Jim's upper T9 S21
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('Jim's upper T9 S21', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_no_valve_s22
default_entity_id: binary_sensor.no_valve_s22
name: (no valve) S22
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('(no valve) S22', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_no_valve_s23
default_entity_id: binary_sensor.no_valve_s23
name: (no valve) S23
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('(no valve) S23', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_blueberries_t1_s24
default_entity_id: binary_sensor.blueberries_t1_s24
name: Blueberries T1 S24
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('Blueberries T1 S24', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_flats_east_t1_s25
default_entity_id: binary_sensor.flats_east_t1_s25
name: flats East T1 S25
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('flats East T1 S25', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_s26
default_entity_id: binary_sensor.s26
name: S26
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('S26', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_s27
default_entity_id: binary_sensor.s27
name: S27
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('S27', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_s28
default_entity_id: binary_sensor.s28
name: S28
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('S28', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_s29
default_entity_id: binary_sensor.s29
name: S29
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('S29', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_s30
default_entity_id: binary_sensor.s30
name: S30
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('S30', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_s31
default_entity_id: binary_sensor.s31
name: S31
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('S31', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
- unique_id: sip_s32
default_entity_id: binary_sensor.s32
name: S32
state_topic: SIP/zones
value_template: "{{ value_json.zone_dict.get('S32', 0) == 1 }}"
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
This will give you 32 binary sensors that represent each valve. You can remove or disable the ones you don’t want.
I used this template to generate the config:
{% set value_json = {
"zone_list": [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
],
"zone_dict": {
"Front T0 S01": 0,
"Courtyard T0 S02": 0,
"North T0 S03": 0,
"south of steps T1 S04": 0,
"(no valve) T1 S05": 0,
"T2 S06": 0,
"T2 S07": 0,
"T3 S08": 0,
"T3 S09": 0,
"(no valve) T4 S10": 0,
"South Hill T4 S11": 0,
"SE Hill T4 S12": 0,
"T5 S13": 0,
"T5 S14": 0,
"SE Hill T6 S15": 0,
"T6 S16": 0,
"T7 S17": 0,
"T8 S18": 0,
"T9 S19": 0,
"Jim's lower T9 S20": 0,
"Jim's upper T9 S21": 0,
"(no valve) S22": 0,
"(no valve) S23": 0,
"Blueberries T1 S24": 0,
"flats East T1 S25": 0,
"S26": 0,
"S27": 0,
"S28": 0,
"S29": 0,
"S30": 0,
"S31": 0,
"S32": 0
},
"master_on": 0
} %}
mqtt:
- binary_sensor:
{%- for k, v in value_json.zone_dict.items() %}
{%- set slug = slugify(k) %}
- unique_id: sip_{{ slug }}
default_entity_id: binary_sensor.{{ slug }}
name: {{ k }}
state_topic: SIP/zones
value_template: {% raw %}"{{ value_json.zone_dict.get('{% endraw %}{{ k }}{% raw %}', 0) == 1 }}"{% endraw %}
device_class: moisture
availability:
- topic: "SIP"
payload_available: "\"UP\""
payload_not_available: "\"DOWN\""
{%- endfor %}
Then, once you incorporate that. Your automation becomes:
triggers:
- trigger: state
entity_id: binary_sensor.courtyard_t0_s02
not_to:
- unknown
- unavailable
actions:
- action: switch.turn_{{ trigger.to_state.state }}
target:
entity_id: switch.start
It also gives you the ability to make binary sensor groups in case you need to turn on that switch with any binary_sensor.
Either way, the upfront configuration is what holds the complication, however it’s managed with a small template if you want to go that route. You can also just manage the 32 switches manually. Still the maintenance burden lessens because your automations become simple and the configuration which rarely changes holds the complication.