Estou a tentar com um sonoff basic por a trabalhar com interuptor de candeeiro.
Penso que tenho tudo bem, mas algo não está direito, pois aparece-me assim.
a configuração está assim como se pode ver na parte final
group:
quarto:
view: yes
name: quarto
entities:
- group.quartogrupo
quartogrupo:
control: hidden
name: Quarto
entities:
- input_number.aberturapersianaquarto
- cover.persianaquarto
- binary_sensor.rele_1
- binary_sensor.rele_2
- switch.candeeiror
input_text:
#Alterar "inicial" para o valor em segundos que o estore demora a abrir desde a posição fechada e vice-versa nos input_text tempodeabertura e tempodefecho.
tempodeaberturaquarto:
name: tempo de maximo de abertura
initial: 22
tempodefechoquarto:
name: tempo de maximo de fecho
initial: 22
iniciofechoquarto:
name: Inicio Fecho Quarto
inicioaberturaquarto:
name: Inicio Abertura Quarto
cover:
- platform: template
covers:
persianaquarto:
friendly_name: "Persiana Quarto"
position_template: '{{ states.input_number.aberturapersianaquarto.state }}'
open_cover:
- service: mqtt.publish
data:
topic: 'cmnd/persianaq/POWER1'
payload: 'ON'
close_cover:
- service: mqtt.publish
data:
topic: 'cmnd/persianaq/POWER2'
payload: 'ON'
stop_cover:
- service: mqtt.publish
data:
topic: 'cmnd/persianaq/Backlog'
payload: 'POWER1 OFF; POWER2 OFF'
binary_sensor:
- platform: mqtt
name: rele 1
state_topic: "stat/persianaq/POWER1"
payload_on: "ON"
payload_off: "OFF"
- platform: mqtt
name: rele 2
state_topic: "stat/persianaq/POWER2"
payload_on: "ON"
payload_off: "OFF"
input_boolean:
alterarsliderquarto:
name: Alterar o Slider Quarto
initial: on
input_number:
aberturapersianaquarto:
name: Abertura
min: 0
max: 100
step: 1
unit_of_measurement: '%'
icon: mdi:blinds
aberturapersianaquartoold:
name: valor antigo de abertura
min: 0
max: 100
step: 1
unit_of_measurement: '%'
automation:
- id: iniciofecho
alias: Começou a fechar Persiana Quarto
trigger:
- platform: state
entity_id: binary_sensor.rele_2
to: 'on'
action:
service: input_text.set_value
data_template:
entity_id: input_text.iniciofechoquarto
value: '{{ now() }}'
- id: fimfecho
alias: Parou de fechar Persiana Quarto
trigger:
- platform: state
entity_id: binary_sensor.rele_2
to: 'off'
condition:
- condition: state
entity_id: input_boolean.alterarsliderquarto
state: 'on'
action:
- service: input_number.set_value
data_template:
entity_id: input_number.aberturapersianaquartoold
value: >-
{% if (states.input_number.aberturapersianaquarto.state)|int - ((as_timestamp(now()) - (as_timestamp(states.input_text.iniciofechoquarto.state))|float|round(2))*100/(states.input_text.tempodefechoquarto.state|int))|int < 4 %}
0
{% else %}
{{ (states.input_number.aberturapersianaquarto.state)|int - ((as_timestamp(now()) - (as_timestamp(states.input_text.iniciofechoquarto.state))|float|round(2))*100/(states.input_text.tempodefechoquarto.state|int))|int }}
{% endif %}
- service: input_number.set_value
data_template:
entity_id: input_number.aberturapersianaquarto
value: '{{ states.input_number.aberturapersianaquartoold.state }}'
- id: inicioabertura
alias: Começou a abrir Persiana Quarto
trigger:
- platform: state
entity_id: binary_sensor.rele_1
to: 'on'
action:
service: input_text.set_value
data_template:
entity_id: input_text.inicioaberturaquarto
value: '{{ now() }}'
- id: fimabertura
alias: Parou de abrir Persiana Quarto
trigger:
- platform: state
entity_id: binary_sensor.rele_1
to: 'off'
condition:
- condition: state
entity_id: 'input_boolean.alterarsliderquarto'
state: 'on'
action:
- service: input_number.set_value
data_template:
entity_id: input_number.aberturapersianaquartoold
value: >-
{% if (states.input_number.aberturapersianaquarto.state)|int + ((as_timestamp(now()) - (as_timestamp(states.input_text.inicioaberturaquarto.state))|float|round(2))*100/(states.input_text.tempodeaberturaquarto.state|int))|int > 96 %}
100
{% else %}
{{ (states.input_number.aberturapersianaquarto.state)|int + ((as_timestamp(now()) - (as_timestamp(states.input_text.inicioaberturaquarto.state))|float|round(2))*100/(states.input_text.tempodeaberturaquarto.state|int))|int }}
{% endif %}
- service: input_number.set_value
data_template:
entity_id: input_number.aberturapersianaquarto
value: '{{ states.input_number.aberturapersianaquartoold.state }}'
- id: aberturapeloslider
alias: Abertura pelo slider Persiana Quarto
trigger:
platform: state
entity_id: input_number.aberturapersianaquarto
condition:
- condition: template
value_template: '{{ states.input_number.aberturapersianaquarto.state|int > states.input_number.aberturapersianaquartoold.state|int }}'
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.alterarsliderquarto
- service: mqtt.publish
data:
topic: 'cmnd/persianaq/Backlog'
payload_template: "POWER1 ON; delay {% if is_state('input_number.aberturapersianaquarto', '100.0') %} {{ (((states.input_number.aberturapersianaquarto.state|int - states.input_number.aberturapersianaquartoold.state|int)*(states.input_text.tempodeaberturaquarto.state|float)/100)|round(1)*10)|round(0) + 20 }} {% else %}
{{ (((states.input_number.aberturapersianaquarto.state|int - states.input_number.aberturapersianaquartoold.state|int)*(states.input_text.tempodeaberturaquarto.state|float)/100)|round(1)*10)|round(0) }} {% endif %}; POWER1 OFF"
- delay:
milliseconds: 800
- wait_template: "{{ is_state('binary_sensor.rele_1', 'off') }}"
- service: input_boolean.turn_on
data:
entity_id: input_boolean.alterarsliderquarto
- service: input_number.set_value
data_template:
entity_id: input_number.aberturapersianaquartoold
value: '{{ states.input_number.aberturapersianaquarto.state }}'
- id: fechopeloslider
alias: Fecho pelo slider Persiana Quarto
trigger:
platform: state
entity_id: input_number.aberturapersianaquarto
condition:
- condition: template
value_template: '{{ states.input_number.aberturapersianaquarto.state|int < states.input_number.aberturapersianaquartoold.state|int }}'
action:
- service: input_boolean.turn_off
data:
entity_id: input_boolean.alterarsliderquarto
- service: mqtt.publish
data:
topic: 'cmnd/persianaq/Backlog'
payload_template: "POWER2 ON; delay {% if is_state('input_number.aberturapersianaquarto', '0.0') %} {{ (((states.input_number.aberturapersianaquartoold.state|int - states.input_number.aberturapersianaquarto.state|int)*(states.input_text.tempodefechoquarto.state|float)/100)|round(1)*10)|round(0) + 20 }} {% else %}
{{ (((states.input_number.aberturapersianaquartoold.state|int - states.input_number.aberturapersianaquarto.state|int)*(states.input_text.tempodefechoquarto.state|float)/100)|round(1)*10)|round(0) }} {% endif %}; POWER2 OFF"
- delay:
milliseconds: 800
- wait_template: "{{ is_state('binary_sensor.rele_2', 'off') }}"
- service: input_boolean.turn_on
data:
entity_id: input_boolean.alterarsliderquarto
- service: input_number.set_value
data_template:
entity_id: input_number.aberturapersianaquartoold
value: '{{ states.input_number.aberturapersianaquarto.state }}'
switch:
- platform: mqtt
name: "candeeiror"
friendly_name: "Candeeiro Rui"
icon: mdi:lamp
state_topic: "stat/candeeiror/POWER"
command_topic: "cmnd/candeeiror/POWER"
availability_topic: "tele/candeeiror/LWT"
payload_available: "Online"
payload_not_available: "Offline"
qos: 1
payload_on: "ON"
payload_off: "OFF"
retain: true
No tasmota está assim
Alguem me pode dizer o que está mal, ou que me falta fazer ??