Изборник Затворити

ESPHome: Sending sensor data to remote URL

It is common need to send data read from sensor or states of device to some remote location, like web site or database. ESPHome allows doing that, and it works pretty well, once you find out how to do it.

For sending data, you can use HTTP GET or POST method. As data usually has some complexity, I prefer using POST and send all info as JSON structure. That is universal way.

First thing you have to use is to include  http_request component into code:

http_request:  
  id: http_request_data
  useragent: esphome/device
  timeout: 10s

You have to set id for component so you can access it later. […]
[ ... види цео чланак ... ]

Example: How to use ESPHome Select Component

ESPHome Select command allows creating entity that has several optional values, allowing one of them to be selected. Unfortunately it is not well documented, so new users have hard time to make it work.

One would expect that Select component should work as simple as setting up options, and that is it. It should set status based on selection on it’s own. but it does not work that way.

After some struggle I finally got it working and here I am making note (mostly to myself) how to do it, as I am sure I would need it again.

select:
  - platform: template
    name: Mode
    id: mode
    options:
     - "OFF"
     - "ON"
     - "AUTO"
    initial_option: "OFF"
    optimistic: true
    set_action:
      - logger.log:
          format: "Selected option: %s"
          args: ["x.c_str()"]
 […]
[ ... види цео чланак ... ]