-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the Tuya-Local-Honeygaridan-S56 wiki!
I have a connection from homeassitent-->app-->homeassitent
I worked several months to get this, now is difficult resume quick, be patient!
I'm a beginner! You will probably find strange solutions, but it works!....for me.
COMNICATION HOMEASISTANT TO APP
Value exsample code inside there are these information
"value": "DAABAQweAgENAAQBDR4DAQ4ABAEOHgYB"
Plan 1: 00001100 00000000 00000001 00000001 --> 12:00 1 meal portion yes planned
Plan 2: 00001100 00011110 00000010 00000001 --> 12:30 2 meal portion yes planned
Plan 3: 00001101 00000000 00000011 00000000 --> 13:00 3 meal portion no planned
Plan 4: 00001101 00011110 00000100 00000001 --> 13:30 4 meal portion yes planned
Plan 5: 00001110 00000000 00000101 00000001 --> 14:00 5 meal portion yes planned
Plan 6: 00001110 00011110 00000110 00000001 --> 14:30 6 meal portion yes planned
to do this i created for each timer 3 entity
- input_datetime
- input_boolean
- input_number
This is a sensor to convert the entity in code
template:
- sensor:
- name: gatti meal plan to app
icon: mdi:calendar-text-outline
state: >-
{% set timer_1_hh = state_attr('input_datetime.gatti_timer_1', "hour") |int %}
{% set timer_1_mm = state_attr('input_datetime.gatti_timer_1', "minute") |int %}
{% set timer_1_meal = states('input_number.gatti_timer_1_porzione_cibo') |round (0) %}
{% set timer_1_enable = iif(is_state('input_boolean.gatti_timer_1_attiva', 'on'), "01", "00") |int %}
{% set timer_2_hh = state_attr('input_datetime.gatti_timer_2', "hour") |int %}
{% set timer_2_mm = state_attr('input_datetime.gatti_timer_2', "minute") |int %}
{% set timer_2_meal = states('input_number.gatti_timer_2_porzione_cibo') |round (0) %}
{% set timer_2_enable = iif(is_state('input_boolean.gatti_timer_2_attiva', 'on'), "01", "00") |int %}
{% set timer_3_hh = state_attr('input_datetime.gatti_timer_3', "hour") |int %}
{% set timer_3_mm = state_attr('input_datetime.gatti_timer_3', "minute") |int %}
{% set timer_3_meal = states('input_number.gatti_timer_3_porzione_cibo') |round (0) %}
{% set timer_3_enable = iif(is_state('input_boolean.gatti_timer_3_attiva', 'on'), "01", "00") |int %}
{% set timer_4_hh = state_attr('input_datetime.gatti_timer_4', "hour") |int %}
{% set timer_4_mm = state_attr('input_datetime.gatti_timer_4', "minute") |int %}
{% set timer_4_meal = states('input_number.gatti_timer_4_porzione_cibo') |round (0) %}
{% set timer_4_enable = iif(is_state('input_boolean.gatti_timer_4_attiva', 'on'), "01", "00") |int %}
{% set timer_5_hh = state_attr('input_datetime.gatti_timer_5', "hour") |int %}
{% set timer_5_mm = state_attr('input_datetime.gatti_timer_5', "minute") |int %}
{% set timer_5_meal = states('input_number.gatti_timer_5_porzione_cibo') |round (0) %}
{% set timer_5_enable = iif(is_state('input_boolean.gatti_timer_5_attiva', 'on'), "01", "00") |int %}
{% set timer_6_hh = state_attr('input_datetime.gatti_timer_6', "hour") |int %}
{% set timer_6_mm = state_attr('input_datetime.gatti_timer_6', "minute") |int %}
{% set timer_6_meal = states('input_number.gatti_timer_6_porzione_cibo') |round (0) %}
{% set timer_6_enable = iif(is_state('input_boolean.gatti_timer_6_attiva', 'on'), "01", "00") |int %}
{% set value_to_app = [timer_1_hh, timer_1_mm, timer_1_meal, timer_1_enable,
timer_2_hh, timer_2_mm, timer_2_meal, timer_2_enable,
timer_3_hh, timer_3_mm, timer_3_meal, timer_3_enable,
timer_4_hh, timer_4_mm, timer_4_meal, timer_4_enable,
timer_5_hh, timer_5_mm, timer_5_meal, timer_5_enable,
timer_6_hh, timer_6_mm, timer_6_meal, timer_6_enable] |list %}
{% if value_to_app | select('in', ['unavailable','unknown', none]) | list | count > 0 -%}
"UNAVALAIBLE"
{% else %}
{% set ns = namespace(x="") %}
{% for b in value_to_app %}
{% set ns.x = ns.x + pack(b, '=B').decode() %}
{% endfor %}
{{ ns.x | base64_encode }}
{% endif %}
the sensor is sended to device whith node red, the flow is here
COMNICATION APP TO HOMEASITANT
Automation
alias: GATTI AGGIORNA PLANNING DA APP
description: >
xxxx
trigger:
- platform: state
entity_id:
- sensor.honeyguaridan_s56_planning
condition:
- condition: template
value_template: >-
{{states('sensor.gatti_meal_plan_to_app') != states
('sensor.honeyguaridan_s56_planning')}}
alias: VERIFICA SE LE STRINGHE DEI PLAN COINCIDONO
action:
- service: notify.persistent_notification
data:
message: >
{{timer_1_hh_plan}} , {{timer_1_mm_plan}} , {{timer_1_meal_plan}} ,
{{timer_1_enable_plan}},<br /> {{value_from_app}},<br />
{{timer_1_hh_app}} , {{timer_1_mm_app}} , {{timer_1_meal_app}} ,
{{timer_1_enable_app}},<br /> 'timer_1_hh_plan == timer_1_hh_app -> '
{{timer_1_hh_plan != timer_1_hh_app}}<br /> 'timer_1_mm_plan ==
timer_1_mm_app -> ' {{timer_1_mm_plan != timer_1_mm_app}}<br />
{{timer_1_hh_plan != timer_1_hh_app or timer_1_mm_plan !=
timer_1_mm_app}}
enabled: false
- alias: >-
TIMER 1 HH:MM - Se ore o minuti sono cambiate setta l'entità
input_datetime allineata con app
if:
- alias: TIMER 1 HH:MM - Verifica se ore e minuti coincidono
condition: or
conditions:
- condition: template
value_template: "{{timer_1_hh_plan != timer_1_hh_app}}"
alias: Verifica ore
- condition: template
value_template: "{{timer_1_mm_plan != timer_1_mm_app}}"
alias: Verifica minuti
then:
- service: input_datetime.set_datetime
data:
time: |
{{timer_1_hh_app | timestamp_custom('%S')}}:{{timer_1_mm_app |
timestamp_custom('%S')}}:00
target:
entity_id: input_datetime.gatti_timer_1
- alias: >-
TIMER 2 HH:MM - Se ore o minuti sono cambiate setta l'entità
input_datetime allineata con app
if:
- alias: TIMER 2 HH:MM - Verifica se ore e minuti coincidono
condition: or
conditions:
- condition: template
value_template: "{{timer_2_hh_plan != timer_2_hh_app}}"
alias: Verifica ore
- condition: template
value_template: "{{timer_2_mm_plan != timer_2_mm_app}}"
alias: Verifica minuti
then:
- service: input_datetime.set_datetime
data:
time: |
{{timer_2_hh_app | timestamp_custom('%S')}}:{{timer_2_mm_app |
timestamp_custom('%S')}}:00
target:
entity_id: input_datetime.gatti_timer_2
- alias: >-
TIMER 3 HH:MM - Se ore o minuti sono cambiate setta l'entità
input_datetime allineata con app
if:
- alias: TIMER 3 HH:MM - Verifica se ore e minuti coincidono
condition: or
conditions:
- condition: template
value_template: "{{timer_3_hh_plan != timer_3_hh_app}}"
alias: Verifica ore
- condition: template
value_template: "{{timer_3_mm_plan != timer_3_mm_app}}"
alias: Verifica minuti
then:
- service: input_datetime.set_datetime
data:
time: |
{{timer_3_hh_app | timestamp_custom('%S')}}:{{timer_3_mm_app |
timestamp_custom('%S')}}:00
target:
entity_id: input_datetime.gatti_timer_3
- alias: >-
TIMER 4 HH:MM - Se ore o minuti sono cambiate setta l'entità
input_datetime allineata con app
if:
- alias: TIMER 4 HH:MM - Verifica se ore e minuti coincidono
condition: or
conditions:
- condition: template
value_template: "{{timer_4_hh_plan != timer_4_hh_app}}"
alias: Verifica ore
- condition: template
value_template: "{{timer_4_mm_plan != timer_4_mm_app}}"
alias: Verifica minuti
then:
- service: input_datetime.set_datetime
data:
time: |
{{timer_4_hh_app | timestamp_custom('%S')}}:{{timer_4_mm_app |
timestamp_custom('%S')}}:00
target:
entity_id: input_datetime.gatti_timer_4
- alias: >-
TIMER 5 HH:MM - Se ore o minuti sono cambiate setta l'entità
input_datetime allineata con app
if:
- alias: TIMER 5 HH:MM - Verifica se ore e minuti coincidono
condition: or
conditions:
- condition: template
value_template: "{{timer_5_hh_plan != timer_5_hh_app}}"
alias: Verifica ore
- condition: template
value_template: "{{timer_5_mm_plan != timer_5_mm_app}}"
alias: Verifica minuti
then:
- service: input_datetime.set_datetime
data:
time: |
{{timer_5_hh_app | timestamp_custom('%S')}}:{{timer_5_mm_app |
timestamp_custom('%S')}}:00
target:
entity_id: input_datetime.gatti_timer_5
- alias: >-
TIMER 6 HH:MM - Se ore o minuti sono cambiate setta l'entità
input_datetime allineata con app
if:
- alias: TIMER 6 HH:MM - Verifica se ore e minuti coincidono
condition: or
conditions:
- condition: template
value_template: "{{timer_6_hh_plan != timer_6_hh_app}}"
alias: Verifica ore
- condition: template
value_template: "{{timer_6_mm_plan != timer_6_mm_app}}"
alias: Verifica minuti
then:
- service: input_datetime.set_datetime
data:
time: |
{{timer_6_hh_app | timestamp_custom('%S')}}:{{timer_6_mm_app |
timestamp_custom('%S')}}:00
target:
entity_id: input_datetime.gatti_timer_6
- alias: >-
TIMER 1 QUANTITA' - Se le quantità sono cambiate setta l'entità
input_number allineata con app
if:
- condition: template
value_template: "{{timer_1_meal_plan != timer_1_meal_app}}"
alias: TIMER 1 QUANTITA' - Verifica se le quantità coincidono
then:
- service: input_number.set_value
data:
value: |
{{timer_1_meal_app |int}}
target:
entity_id: input_number.gatti_timer_1_porzione_cibo
- alias: >-
TIMER 2 QUANTITA' - Se le quantità sono cambiate setta l'entità
input_number allineata con app
if:
- condition: template
value_template: "{{timer_2_meal_plan != timer_2_meal_app}}"
alias: TIMER 2 QUANTITA' - Verifica se le quantità coincidono
then:
- service: input_number.set_value
data:
value: |
{{timer_2_meal_app |int}}
target:
entity_id: input_number.gatti_timer_2_porzione_cibo
- alias: >-
TIMER 3 QUANTITA' - Se le quantità sono cambiate setta l'entità
input_number allineata con app
if:
- condition: template
value_template: "{{timer_3_meal_plan != timer_3_meal_app}}"
alias: TIMER 3 QUANTITA' - Verifica se le quantità coincidono
then:
- service: input_number.set_value
data:
value: |
{{timer_3_meal_app |int}}
target:
entity_id: input_number.gatti_timer_3_porzione_cibo
- alias: >-
TIMER 4 QUANTITA' - Se le quantità sono cambiate setta l'entità
input_number allineata con app
if:
- condition: template
value_template: "{{timer_4_meal_plan != timer_4_meal_app}}"
alias: TIMER 4 QUANTITA' - Verifica se le quantità coincidono
then:
- service: input_number.set_value
data:
value: |
{{timer_4_meal_app |int}}
target:
entity_id: input_number.gatti_timer_4_porzione_cibo
- alias: >-
TIMER 5 QUANTITA' - Se le quantità sono cambiate setta l'entità
input_number allineata con app
if:
- condition: template
value_template: "{{timer_5_meal_plan != timer_5_meal_app}}"
alias: TIMER 5 QUANTITA' - Verifica se le quantità coincidono
then:
- service: input_number.set_value
data:
value: |
{{timer_5_meal_app |int}}
target:
entity_id: input_number.gatti_timer_5_porzione_cibo
- alias: >-
TIMER 6 QUANTITA' - Se le quantità sono cambiate setta l'entità
input_number allineata con app
if:
- condition: template
value_template: "{{timer_6_meal_plan != timer_6_meal_app}}"
alias: TIMER 6 QUANTITA' - Verifica se le quantità coincidono
then:
- service: input_number.set_value
data:
value: |
{{timer_6_meal_app |int}}
target:
entity_id: input_number.gatti_timer_6_porzione_cibo
- alias: >-
TIMER 1 ABILITATO - Se le abilitazioni sono cambiate setta l'entità
input_boolean allineata con app
if:
- condition: template
value_template: "{{timer_1_enable_plan != timer_1_enable_app}}"
alias: TIMER 1 ABILITATO - Verifica se le abilitazioni coincidono
then:
- if:
- condition: template
value_template: "{{timer_1_enable_app == 1}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.gatti_timer_1_attiva
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.gatti_timer_1_attiva
alias: >-
Necessaria istruzione if perche non esiste un set per input_boolean ma
solo on o off
- alias: >-
TIMER 2 ABILITATO - Se le abilitazioni sono cambiate setta l'entità
input_boolean allineata con app
if:
- condition: template
value_template: "{{timer_2_enable_plan != timer_2_enable_app}}"
alias: TIMER 2 ABILITATO - Verifica se le abilitazioni coincidono
then:
- if:
- condition: template
value_template: "{{timer_2_enable_app == 1}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.gatti_timer_2_attiva
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.gatti_timer_2_attiva
alias: >-
Necessaria istruzione if perche non esiste un set per input_boolean ma
solo on o off
- alias: >-
TIMER 3 ABILITATO - Se le abilitazioni sono cambiate setta l'entità
input_boolean allineata con app
if:
- condition: template
value_template: "{{timer_3_enable_plan != timer_3_enable_app}}"
alias: TIMER 3 ABILITATO - Verifica se le abilitazioni coincidono
then:
- if:
- condition: template
value_template: "{{timer_3_enable_app == 1}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.gatti_timer_3_attiva
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.gatti_timer_3_attiva
alias: >-
Necessaria istruzione if perche non esiste un set per input_boolean ma
solo on o off
- alias: >-
TIMER 4 ABILITATO - Se le abilitazioni sono cambiate setta l'entità
input_boolean allineata con app
if:
- condition: template
value_template: "{{timer_4_enable_plan != timer_4_enable_app}}"
alias: TIMER 4 ABILITATO - Verifica se le abilitazioni coincidono
then:
- if:
- condition: template
value_template: "{{timer_4_enable_app == 1}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.gatti_timer_4_attiva
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.gatti_timer_4_attiva
alias: >-
Necessaria istruzione if perche non esiste un set per input_boolean ma
solo on o off
- alias: >-
TIMER 5 ABILITATO - Se le abilitazioni sono cambiate setta l'entità
input_boolean allineata con app
if:
- condition: template
value_template: "{{timer_5_enable_plan != timer_5_enable_app}}"
alias: TIMER 5 ABILITATO - Verifica se le abilitazioni coincidono
then:
- if:
- condition: template
value_template: "{{timer_5_enable_app == 1}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.gatti_timer_5_attiva
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.gatti_timer_5_attiva
alias: >-
Necessaria istruzione if perche non esiste un set per input_boolean ma
solo on o off
- alias: >-
TIMER 6 ABILITATO - Se le abilitazioni sono cambiate setta l'entità
input_boolean allineata con app
if:
- condition: template
value_template: "{{timer_6_enable_plan != timer_6_enable_app}}"
alias: TIMER 6 ABILITATO - Verifica se le abilitazioni coincidono
then:
- if:
- condition: template
value_template: "{{timer_6_enable_app == 1}}"
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.gatti_timer_6_attiva
else:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.gatti_timer_6_attiva
alias: >-
Necessaria istruzione if perche non esiste un set per input_boolean ma
solo on o off
variables:
timer_1_hh_plan: >
{{ state_attr('input_datetime.gatti_timer_1', "hour") |
timestamp_custom('%S')}}
timer_1_mm_plan: >
{{ state_attr('input_datetime.gatti_timer_1', "minute") |
timestamp_custom('%S')}}
timer_1_meal_plan: |
{{ states('input_number.gatti_timer_1_porzione_cibo') | round (0) }}
timer_1_enable_plan: >
{{ iif(is_state('input_boolean.gatti_timer_1_attiva', 'on'), "01", "00") |
int }}
timer_2_hh_plan: >
{{ state_attr('input_datetime.gatti_timer_2', "hour") |
timestamp_custom('%S')}}
timer_2_mm_plan: >
{{ state_attr('input_datetime.gatti_timer_2', "minute") |
timestamp_custom('%S')}}
timer_2_meal_plan: |
{{ states('input_number.gatti_timer_2_porzione_cibo') | round (0) }}
timer_2_enable_plan: >
{{ iif(is_state('input_boolean.gatti_timer_2_attiva', 'on'), "01", "00") |
int }}
timer_3_hh_plan: >
{{ state_attr('input_datetime.gatti_timer_3', "hour") |
timestamp_custom('%S')}}
timer_3_mm_plan: >
{{ state_attr('input_datetime.gatti_timer_3', "minute") |
timestamp_custom('%S')}}
timer_3_meal_plan: |
{{ states('input_number.gatti_timer_3_porzione_cibo') | round (0) }}
timer_3_enable_plan: >
{{ iif(is_state('input_boolean.gatti_timer_3_attiva', 'on'), "01", "00") |
int }}
timer_4_hh_plan: >
{{ state_attr('input_datetime.gatti_timer_4', "hour") |
timestamp_custom('%S')}}
timer_4_mm_plan: >
{{ state_attr('input_datetime.gatti_timer_4', "minute") |
timestamp_custom('%S')}}
timer_4_meal_plan: |
{{ states('input_number.gatti_timer_4_porzione_cibo') | round (0) }}
timer_4_enable_plan: >
{{ iif(is_state('input_boolean.gatti_timer_4_attiva', 'on'), "01", "00") |
int }}
timer_5_hh_plan: >
{{ state_attr('input_datetime.gatti_timer_5', "hour") |
timestamp_custom('%S')}}
timer_5_mm_plan: >
{{ state_attr('input_datetime.gatti_timer_5', "minute") |
timestamp_custom('%S')}}
timer_5_meal_plan: |
{{ states('input_number.gatti_timer_5_porzione_cibo') | round (0) }}
timer_5_enable_plan: >
{{ iif(is_state('input_boolean.gatti_timer_5_attiva', 'on'), "01", "00") |
int }}
timer_6_hh_plan: >
{{ state_attr('input_datetime.gatti_timer_6', "hour") |
timestamp_custom('%S')}}
timer_6_mm_plan: >
{{ state_attr('input_datetime.gatti_timer_6', "minute") |
timestamp_custom('%S')}}
timer_6_meal_plan: |
{{ states('input_number.gatti_timer_6_porzione_cibo') | round (0) }}
timer_6_enable_plan: >
{{ iif(is_state('input_boolean.gatti_timer_6_attiva', 'on'), "01", "00") |
int }}
value_from_app: |
{{ states('sensor.honeyguaridan_s56_planning') }}
timer_1_hh_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[0] }}
timer_1_mm_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[1] }}
timer_1_meal_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[2] }}
timer_1_enable_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[3] }}
timer_2_hh_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[4] }}
timer_2_mm_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[5] }}
timer_2_meal_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[6] }}
timer_2_enable_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[7] }}
timer_3_hh_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[8] }}
timer_3_mm_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[9] }}
timer_3_meal_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[10] }}
timer_3_enable_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[11] }}
timer_4_hh_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[12] }}
timer_4_mm_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[13] }}
timer_4_meal_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[14] }}
timer_4_enable_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[15] }}
timer_5_hh_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[16] }}
timer_5_mm_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[17] }}
timer_5_meal_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[18] }}
timer_5_enable_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[19] }}
timer_6_hh_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[20] }}
timer_6_mm_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[21] }}
timer_6_meal_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[22] }}
timer_6_enable_app: |
{{ (( value_from_app | base64_decode).encode() | map('int') | list)[23] }}
mode: single