Joshua
(SERGIO NUVOLONI)
September 12, 2020, 2:28pm
1
Hi everyone,
with a nextion display I am making a control to turn on the lights and close the terrace curtains. I am using, for shelly 1 lights and 2.5 for shelly curtains. I connected the nextion display with a NODE MCU and everything seems to work. Checking the ESPhome logs in HA I get the following error message when using shelly 2.5: Can’t convert ‘opening’ to binary state! the curtain opens and closes but I cannot change the image in the display.
Any idea ???
Thanks for your help.
Regards.
Following part of the script:
display:
platform: nextion
lambda: |-
it.set_wait_for_ack(false);
if (id(Luce_Terrazzo).state) {
it.send_command_printf("%s.pic=5", “luce”);
}
else {
it.send_command_printf("%s.pic=4", “luce”);
}
if (id(Tenda_Terrazzo_Grande).state) {
it.send_command_printf("%s.pic=8", “tenda1”);
}
else {
it.send_command_printf("%s.pic=7", “tenda1”);
}
tom_l
September 12, 2020, 6:57pm
2
Please format your pasted code.
Binary states are ‘off’ and ‘on’ only. Your shelly is sending ‘opening’ when it should send ‘on’.
If you want three or more states (e.g. open, closed, opening) use a sensor rather than a binary_sensor.
1 Like
Joshua
(SERGIO NUVOLONI)
September 13, 2020, 8:43am
3
Hi Tom,
thanks for your help.
I try to set sensor but unfortunately without success.
How can I format the code properly?
Thanks in advance for your help.
Ciao .
Sergio.
Following the code.
esphome:
name: display_one
platform: ESP8266
board: nodemcuv2
wifi:
ssid: "xxxxx"
password: "xxxxxx"
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Display One Fallback Hotspot"
password: "xxxxxx"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: "xxxxx"
ota:
password: "xxxxx"
uart:
rx_pin: D3
tx_pin: D1
baud_rate: 9600
binary_sensor:
- platform: homeassistant
id: Luce_Terrazzo
name: "Switch Luce terrazzo"
entity_id: switch.shelly_shsw_1_e0eba8
- platform: homeassistant
id: Tenda_Terrazzo_Grande
name: "Switch Tenda Terrazzo Grande"
entity_id: cover.shelly_shsw_25_73677f
#Luce Terrazzo
- platform: nextion
page_id: 0
component_id: 2
name: Luce Terrazzo switch_on
on_press:
then:
- homeassistant.service:
service: homeassistant.turn_on
data:
entity_id: switch.shelly_shsw_1_e0eba8
- platform: nextion
page_id: 0
component_id: 3
name : Luce Terrazzo Switch_off
on_press:
then:
- homeassistant.service:
service: homeassistant.turn_off
data:
entity_id: switch.shelly_shsw_1_e0eba8
# Tenda Terrazzo Grande
- platform: nextion
page_id: 0
component_id: 5
name: Tenda Grande Open
on_press:
then:
- homeassistant.service:
service: cover.open_cover
data:
entity_id: cover.shelly_shsw_25_73677f
- platform: nextion
page_id: 0
component_id: 7
name: Tenda Grande Closed
on_press:
then:
- homeassistant.service:
service: cover.close_cover
data:
entity_id: cover.shelly_shsw_25_73677f
- platform: nextion
page_id: 0
component_id: 6
name: Tenda Grande Stop
on_press:
then:
- homeassistant.service:
service: cover.stop_cover
data:
entity_id: cover.shelly_shsw_25_73677f
sensor:
- platform: homeassistant
id: Tenda_Grande
entity_id: cover.shelly_shsw_25_73677f
display:
- platform: nextion
lambda: |-
it.set_wait_for_ack(false);
if (id(Luce_Terrazzo).state) {
it.send_command_printf("%s.pic=5", "luce");
}
else {
it.send_command_printf("%s.pic=4", "luce");
}
if (id(Tenda_Grande).state) {
it.send_command_printf("%s.pic=7", "tenda1");
}
else {
it.send_command_printf("%s.pic=8", "tenda1");
}