Homeassistant.service multi-calls

Hello All,
I’m having an issue with the configuration of my ESP32 connected to a nextion display that should be used as HMI for air-conditioning control.

In the interface there’s the possibility to change the setpoint via two different buttons: each button procedure an own action in esphome.

The problem is that it works only for the first call. All other calls are ignored.

Please find below the extract of esphome configuration:

uart:
  rx_pin: 16
  tx_pin: 17
  baud_rate: 9600
    
binary_sensor:
  - platform: ble_presence
    mac_address: 88:11:96:55:C3:2D
    name: "HUAWEI Band 3 Pro"
  - platform: nextion
    id: climate_living_increase
    page_id: 1
    component_id: 6
    on_press:
      - homeassistant.service: 
          service: climate.set_temperature
          data:
            entity_id: "climate.living"
          data_template:
            temperature: |
              {{ state_attr("climate.living", "temperature") + 0.5 }}
  - platform: nextion
    id: climate_living_decrease
    page_id: 1
    component_id: 7
    on_release:
      - then:
        - homeassistant.service: 
            service: climate.set_temperature
            data:
              entity_id: "climate.living"
            data_template:
              temperature: |
                {{ state_attr("climate.living", "temperature") - 0.5 }}
sensor:
  - platform: xiaomi_lywsdcgq
    mac_address: 58:2D:34:31:AC:9F
    temperature:
      name: "Temperatura Living"
      id: temp_living
    humidity:
      name: "Umidità Living"
      id: hum_living
    battery_level:
      name: "Batteria termometro living"
  - platform: xiaomi_lywsdcgq
    mac_address: 4C:65:A8:DD:D4:4C
    temperature:
      name: "Temperatura Camera"
      id: temp_camera
    humidity:
      name: "Umidità Camera"
      id: hum_camera
    battery_level:
      name: "Batteria termometro camera"
  - platform: homeassistant
    entity_id: sensor.climate_setpoint_living
    id: setpoint_living
    on_value:
       then:
         - lambda: 'id(hmi).set_component_value("living.target", int(id(setpoint_living).state * 10));'
display:
  - platform: nextion
    id: hmi
    lambda: |-
      it.set_component_value("living.temperature", int(id(temp_living).state*10));
      it.set_component_value("living.target", int(id(setpoint_living).state*10));
      it.set_component_value("living.humidity", int(id(hum_living).state*10));
      it.set_component_value("bed.temperature", int(id(temp_camera).state*10));
      it.set_component_value("bed.humidity", int(id(hum_camera).state*10));

Thanks in advance for helping.

Salvo

Hello,
I solved the issue. Actually the problem, I think, is in binary_sensor module.
Infact, when I press the button on display first time, the relative binary_sensor goes to True and run the action, but then it reaches a dead-lock situation because it cannot trigger the on_press event if it is not reset before.

The code to work-around it is:

  - platform: nextion
    id: climate_living_increase
    page_id: 1
    component_id: 6
    on_press:
      - homeassistant.service: 
          service: climate.set_temperature
          data:
            entity_id: "climate.living"
          data_template:
            temperature: |
              {{ state_attr("climate.living", "temperature") + 0.5 }}
      - lambda: "id(climate_living_increase).publish_state(false);"

I hope that someone else can help me showing me how to fix the problem better.

Regards,
Salvo

2 Likes

Grazie… stavo cercando il modo di impostare la temperatura e grazie al tuo esempio ho risolto :slight_smile:

I had this issue you need to make sure in the nextion IDE that both the touch press & touch release events are set to send component ID (The tick box ) on the button component

1 Like

Thank you SOOO much!! I had been goofing with this for 3 hours!

I did confirm that sending the componentID for both press and release events works as well. Thanks @pebblebed