OK. Here’s how I’ll do it (sorry I’m French so I’ll let you change the friendly names to your liking):
in configuration.yaml:
sensor:
- platform: rest
resource: !secret hozelock_controller_0
name: "Hozelock Controller 0"
value_template: '{{ value_json["controller"]["name"] }}'
json_attributes:
- controller
- platform: template
sensors:
hozelock_controller_0_pause_starttime:
friendly_name: "Début pause"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['pause'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["pause"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_pause_endtime:
friendly_name: "Fin pause"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['pause'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["pause"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_pause_duration:
friendly_name: "Durée pause"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['pause'] %}
{{ state_attr("sensor.hozelock_controller_0", "controller")["pause"]["duration"] | int / 86400000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'j'
hozelock_controller_0_adjustment_starttime:
friendly_name: "Début ajustement"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['adjustment'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["adjustment"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_adjustment_endtime:
friendly_name: "Fin ajustement"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['adjustment'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["adjustment"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_adjustment_wateringadjustment:
friendly_name: "Quantité ajustement"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['adjustment'] %}
{{ state_attr("sensor.hozelock_controller_0", "controller")["adjustment"]["wateringAdjustment"] }}
{% else %}
unknown
{% endif %}
unit_of_measurement: '%'
hozelock_controller_0_waternowevent_starttime:
friendly_name: "Arrosage manuel (début)"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['waterNowEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["waterNowEvent"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_waternowevent_endtime:
friendly_name: "Arrosage manuel (fin)"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['waterNowEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["waterNowEvent"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_waternowevent_duration:
friendly_name: "Arrosage manuel (durée)"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['waterNowEvent'] %}
{{ state_attr("sensor.hozelock_controller_0", "controller")["waterNowEvent"]["duration"] | int / 60000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'min'
hozelock_controller_0_currentwateringevent_starttime:
friendly_name: "Arrosage en cours (début)"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['currentWateringEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["currentWateringEvent"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_currentwateringevent_endtime:
friendly_name: "Arrosage en cours (fin)"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['currentWateringEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["currentWateringEvent"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_currentwateringevent_duration:
friendly_name: "Arrosage en cours (durée)"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['currentWateringEvent'] %}
{{ state_attr("sensor.hozelock_controller_0", "controller")["currentWateringEvent"]["duration"] | int / 60000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'min'
hozelock_controller_0_nextwateringevent_starttime:
friendly_name: "Prochain arrosage (début)"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['nextWateringEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["nextWateringEvent"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_nextwateringevent_endtime:
friendly_name: "Prochain arrosage (fin)"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['nextWateringEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_0", "controller")["nextWateringEvent"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_0_nextwateringevent_duration:
friendly_name: "Prochain arrosage (durée)"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['nextWateringEvent'] %}
{{ state_attr("sensor.hozelock_controller_0", "controller")["nextWateringEvent"]["duration"] | int / 60000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'min'
hozelock_controller_0_lastcommunicationwithserver:
friendly_name: "Dernière communication"
value_template: '{{ ( state_attr("sensor.hozelock_controller_0", "controller")["lastCommunicationWithServer"] | int / 1000 ) | int | timestamp_local }}'
hozelock_controller_0_nextcommunicationwithserver:
friendly_name: "Prochaine communication"
value_template: '{{ ( state_attr("sensor.hozelock_controller_0", "controller")["nextCommunicationWithServer"] | int / 1000 ) | int | timestamp_local }}'
hozelock_controller_0_batterystatus:
friendly_name: "Etat batterie"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["batteryStatus"] }}'
hozelock_controller_0_signalstrength:
friendly_name: "Puissance signal"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["signalStrength"] }}'
hozelock_controller_0_overridescheduleduration:
friendly_name: "Remplacement durée prog"
value_template: >-
{% if states.sensor.hozelock_controller_0.attributes.controller['overrideScheduleDuration'] %}
{{ state_attr("sensor.hozelock_controller_0", "controller")["overrideScheduleDuration"] | int / 60000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'min'
- platform: rest
resource: !secret hozelock_controller_1
name: "Hozelock Controller 1"
value_template: '{{ value_json["controller"]["name"] }}'
json_attributes:
- controller
- platform: template
sensors:
hozelock_controller_1_pause_starttime:
friendly_name: "Début pause"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['pause'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["pause"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_pause_endtime:
friendly_name: "Fin pause"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['pause'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["pause"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_pause_duration:
friendly_name: "Durée pause"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['pause'] %}
{{ state_attr("sensor.hozelock_controller_1", "controller")["pause"]["duration"] | int / 86400000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'j'
hozelock_controller_1_adjustment_starttime:
friendly_name: "Début ajustement"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['adjustment'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["adjustment"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_adjustment_endtime:
friendly_name: "Fin ajustement"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['adjustment'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["adjustment"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_adjustment_wateringadjustment:
friendly_name: "Quantité ajustement"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['adjustment'] %}
{{ state_attr("sensor.hozelock_controller_1", "controller")["adjustment"]["wateringAdjustment"] }}
{% else %}
unknown
{% endif %}
unit_of_measurement: '%'
hozelock_controller_1_waternowevent_starttime:
friendly_name: "Arrosage manuel (début)"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['waterNowEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["waterNowEvent"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_waternowevent_endtime:
friendly_name: "Arrosage manuel (fin)"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['waterNowEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["waterNowEvent"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_waternowevent_duration:
friendly_name: "Arrosage manuel (durée)"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['waterNowEvent'] %}
{{ state_attr("sensor.hozelock_controller_1", "controller")["waterNowEvent"]["duration"] | int / 60000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'min'
hozelock_controller_1_currentwateringevent_starttime:
friendly_name: "Arrosage en cours (début)"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['currentWateringEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["currentWateringEvent"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_currentwateringevent_endtime:
friendly_name: "Arrosage en cours (fin)"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['currentWateringEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["currentWateringEvent"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_currentwateringevent_duration:
friendly_name: "Arrosage en cours (durée)"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['currentWateringEvent'] %}
{{ state_attr("sensor.hozelock_controller_1", "controller")["currentWateringEvent"]["duration"] | int / 60000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'min'
hozelock_controller_1_nextwateringevent_starttime:
friendly_name: "Prochain arrosage (début)"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['nextWateringEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["nextWateringEvent"]["startTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_nextwateringevent_endtime:
friendly_name: "Prochain arrosage (fin)"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['nextWateringEvent'] %}
{{ ( state_attr("sensor.hozelock_controller_1", "controller")["nextWateringEvent"]["endTime"] | int / 1000 ) | int | timestamp_local }}
{% else %}
unknown
{% endif %}
hozelock_controller_1_nextwateringevent_duration:
friendly_name: "Prochain arrosage (durée)"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['nextWateringEvent'] %}
{{ state_attr("sensor.hozelock_controller_1", "controller")["nextWateringEvent"]["duration"] | int / 60000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'min'
hozelock_controller_1_lastcommunicationwithserver:
friendly_name: "Dernière communication"
value_template: '{{ ( state_attr("sensor.hozelock_controller_1", "controller")["lastCommunicationWithServer"] | int / 1000 ) | int | timestamp_local }}'
hozelock_controller_1_nextcommunicationwithserver:
friendly_name: "Prochaine communication"
value_template: '{{ ( state_attr("sensor.hozelock_controller_1", "controller")["nextCommunicationWithServer"] | int / 1000 ) | int | timestamp_local }}'
hozelock_controller_1_batterystatus:
friendly_name: "Etat batterie"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["batteryStatus"] }}'
hozelock_controller_1_signalstrength:
friendly_name: "Puissance signal"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["signalStrength"] }}'
hozelock_controller_1_overridescheduleduration:
friendly_name: "Remplacement durée prog"
value_template: >-
{% if states.sensor.hozelock_controller_1.attributes.controller['overrideScheduleDuration'] %}
{{ state_attr("sensor.hozelock_controller_1", "controller")["overrideScheduleDuration"] | int / 60000 | int }}
{% else %}
unknown
{% endif %}
unit_of_measurement: 'min'
binary_sensor:
- platform: template
sensors:
hozelock_controller_0_haswaternowevent:
friendly_name: "Arrosage manuel"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["hasWaterNowEvent"] }}'
hozelock_controller_0_ischildlockenabled:
friendly_name: "Verrou enfant"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["isChildlockEnabled"] }}'
hozelock_controller_0_iswatering:
friendly_name: "Arrosage en cours"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["isWatering"] }}'
hozelock_controller_0_ispanelremoved:
friendly_name: "Panneau retiré"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["isPanelRemoved"] }}'
hozelock_controller_0_isadjusted:
friendly_name: "Ajustement"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["isAdjusted"] }}'
hozelock_controller_0_isscheduleuptodate:
friendly_name: "Calendrier à jour"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["isScheduleUpToDate"] }}'
hozelock_controller_0_ispaused:
friendly_name: "En pause"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["isPaused"] }}'
hozelock_controller_0_nextwateringevent_enabled:
friendly_name: "Prochain arrosage activé"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["nextWateringEvent"]["enabled"] }}'
hozelock_controller_0_currentwateringevent_enabled:
friendly_name: "Arrosage en cours (activé)"
value_template: '{{ state_attr("sensor.hozelock_controller_0", "controller")["currentWateringEvent"]["enabled"] }}'
- platform: template
sensors:
hozelock_controller_1_haswaternowevent:
friendly_name: "Arrosage manuel"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["hasWaterNowEvent"] }}'
hozelock_controller_1_ischildlockenabled:
friendly_name: "Verrou enfant"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["isChildlockEnabled"] }}'
hozelock_controller_1_iswatering:
friendly_name: "Arrosage en cours"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["isWatering"] }}'
hozelock_controller_1_ispanelremoved:
friendly_name: "Panneau retiré"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["isPanelRemoved"] }}'
hozelock_controller_1_isadjusted:
friendly_name: "Ajustement"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["isAdjusted"] }}'
hozelock_controller_1_isscheduleuptodate:
friendly_name: "Calendrier à jour"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["isScheduleUpToDate"] }}'
hozelock_controller_1_ispaused:
friendly_name: "En pause"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["isPaused"] }}'
hozelock_controller_1_nextwateringevent_enabled:
friendly_name: "Prochain arrosage activé"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["nextWateringEvent"]["enabled"] }}'
hozelock_controller_1_currentwateringevent_enabled:
friendly_name: "Arrosage en cours (activé)"
value_template: '{{ state_attr("sensor.hozelock_controller_1", "controller")["currentWateringEvent"]["enabled"] }}'
rest_command:
hozelock_waternow:
url: https://hoz3.com/restful/support/hubs/{{ hub_id }}/controllers/actions/waterNow
method: POST
payload: '{"controllerIDs":[ {{ controller_id }} ],"duration": {{ duration }} }'
content_type: 'application/json'
hozelock_stopwatering:
url: https://hoz3.com/restful/support/hubs/{{ hub_id }}/controllers/actions/stopWatering
method: POST
payload: '{"controllerIDs":[ {{ controller_id }} ]}'
content_type: 'application/json'
hozelock_pause:
url: https://hoz3.com/restful/support/hubs/{{ hub_id }}/controllers/actions/pause
method: POST
payload: '{"controllerIDs":[ {{ controller_id }} ],"duration": {{ duration }} }'
content_type: 'application/json'
hozelock_unpause:
url: https://hoz3.com/restful/support/hubs/{{ hub_id }}/controllers/actions/unpause
method: POST
payload: '{"controllerIDs":[ {{ controller_id }} ]}'
content_type: 'application/json'
In secrets.yaml:
hozelock_hub_id: XXXXXX
hozelock_controller_0: https://hoz3.com/restful/support/hubs/XXXXXX/controllers/0
hozelock_controller_1: https://hoz3.com/restful/support/hubs/XXXXXX/controllers/1
In script.yaml:
hozelock_waternow_0:
alias: Démarrer arrosage manuel
sequence:
- service: rest_command.hozelock_waternow
data_template:
hub_id: !secret hozelock_hub_id
controller_id: 0
duration: "{{ states('input_number.hozelock_duration') | int * 60000 }}"
hozelock_stopwatering_0:
alias: Arrêter arrosage manuel
sequence:
- service: rest_command.hozelock_waternow
data_template:
hub_id: !secret hozelock_hub_id
controller_id: 0
hozelock_pause_0:
alias: Suspendre arrosage
sequence:
- service: rest_command.hozelock_pause
data_template:
hub_id: !secret hozelock_hub_id
controller_id: 0
duration: "{{ states('input_number.hozelock_duration_pause') }}"
hozelock_unpause_0:
alias: Reprise arrosage
sequence:
- service: rest_command.hozelock_unpause
data_template:
hub_id: !secret hozelock_hub_id
controller_id: 0
hozelock_waternow_1:
alias: Démarrer arrosage manuel
sequence:
- service: rest_command.hozelock_waternow
data_template:
hub_id: !secret hozelock_hub_id
controller_id: 1
duration: "{{ states('input_number.hozelock_duration') | int * 60000 }}"
hozelock_stopwatering_1:
alias: Arrêter arrosage manuel
sequence:
- service: rest_command.hozelock_waternow
data_template:
hub_id: !secret hozelock_hub_id
controller_id: 1
hozelock_pause_1:
alias: Suspendre arrosage
sequence:
- service: rest_command.hozelock_pause
data_template:
hub_id: !secret hozelock_hub_id
controller_id: 1
duration: "{{ states('input_number.hozelock_duration_pause') }}"
hozelock_unpause_1:
alias: Reprise arrosage
sequence:
- service: rest_command.hozelock_unpause
data_template:
hub_id: !secret hozelock_hub_id
controller_id: 1