Is it possible to create a sensor with ESPHOME that is later working in a remote location and transmits its values via webhook.
e.g to monitor the temperature at work and push the data to my HA at home via webhook. At work there is a WLAN for this.
Creating a local sensor for this task is very easy, but i don’t know how to push the data via webhook.
I want to keep the data as private as possible and my local HA isnt exposed to the internet.
In the past, I have done something similar using the following setup:
Remote sensor posts values to a could based mqtt server. I used CloudMQTT (free).
HA’s mqtt server is configured to mirror cloud values to local mqtt instance.
HA configured for a regular MQTT sensor.
Doesn’t require HA to be exposed to internet. Traffic to and from cloud MQTT server can be encrypted with SSL.
This isn’t an easy setup though. Especially the part for configuring MQTT mirroring. I wrote up a forum post a few years back with instructions though.
Well, i dislike the mqtt way, but this is my personal taste.
I will take a look at ESP-Easy and mycropython. I am not sure if both are able to call https://-urls.
" . The payload is available in an automation template as either trigger.json or trigger.data . URL query parameters are available in the template as trigger.query . Remember to use an HTTPS URL if you’ve secured your Home Assistant installation with SSL/TLS."
So if you include data in the POST, then you can get it via a template as trigger.json or trigger.data . If you included it as a parameter in the GET, it is trigger.query.
No VPN needed if you have webhooks exposed, just include your data in the HTTP request.
Not yet finished but putting data to a webhook works. To store the data i will use a input_number and update the value within an automation using the service input_number.set_value
Can confirm this to work. ESPHome node in remote location and webhook via nabu casa.
It is old thread but I had some problems to make this so posting here.
Only thing I couln’t figure out yet how to make sensors on HA side with only one webhook.
I’m sending two temperature values in json and than comes through just fine. But seems that HA can trigger only once to one webhook.
This was in HA and only the first one works. Second fails with log input that webhook id already in use. So if you use only one sensor this works or create a second webhook for the other.
template:
- trigger:
- platform: webhook
webhook_id: <webhook id 1>
sensor:
- name: "ilp_temp"
state: "{{trigger.json.ilp_temp}}"
unit_of_measurement: "°C"
- trigger:
- platform: webhook
#NOTE: Doesnt work with the same hook id
webhook_id: <webhook id 1>
sensor:
- name: "cabinet_temp"
state: "{{trigger.json.cabinet_temp}}"
unit_of_measurement: "°C"
I used node red then to create a webhook and split the sensors to HA. Nore red created webhook id is also on the ESPHome. Just activate it from the cloud page and use the nabu casa hook, not the one with local IP.
One more caveat to here is that sensor decimals doesnt get cut. Have to figure out that still but at least it works now. Have to get rid of those and apply some filtering.
It sends the values every 5 minutes. On the home assistant side I use an automation triggered by the web hook. In this automation I set the received values to helpers.
{{trigger.json.Feuchte | round(1) }}
So you can handle all values from the remote sensor in one automation.