Esphome using sht3xd and http request

Hi, it seems that shtx3d sensor does not support “on_value”. It says “[on_value] is an invalid option for [sensor.sht3xd]. Please check the indentation.”, How can I send http request after succesful sensor read?

Show your esphome sensor configuration.

i2c:
  sda: 4
  scl: 5
  scan: true
  id: bus_a
  
# Example configuration entry
sensor:
  - platform: sht3xd
    temperature:
      name: "Outdoor Temperature"
    humidity:
      name: "Outdoor Humidity"
    address: 0x44
    update_interval: 60s
    on_value:
      then:
        - http_request.post:
            url: !lambda |-
                return ((std::string) "https://api.thingspeak.com/update?api_key=******************&field1=" + id(Outdoor Temperature).state).c_str() + "&field2=" + id(Outdoor Humidity).state).c_str();

Yeah I think you have on_value in the wrong spot. On which value?

Temperature or humidity?

Try it in these two places:

sensor:
  - platform: sht3xd
    temperature:
      name: "Outdoor Temperature"
      on_value:
        then: ...
    humidity:
      name: "Outdoor Humidity"
      on_value:
        then: ...
    address: 0x44
    update_interval: 60s
    on_value:
      then:

Will try, thanks!

Now I get duplicate “on_value” error…

You could open an issue here:

Yes - sounds like a bug with the component. I just tested with a BMP280 and it works fine:

sensor:
  - platform: bmp280
    temperature:
      name: "Man Cave Temperature"
      oversampling: 16x
      on_value:
        then:
          - logger.log: "Temperature"
    pressure:
      name: "Man Cave Air Pressure"
      on_value:
        then:
          - logger.log: "Pressure"
    address: 0x76
    update_interval: 60s