-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automation between nodes #52
Automation between nodes #52
Comments
This will be a part of #46 However, the ESPs will not communicate directly with each other. They will communicate through the central native API broker. Why? ESPs have very little resources, and I have the strong feeling people will create a network where each ESP is connected to each other ESP. Even with only a couple of ESPs that will quickly kill all resources. That of course means there will be a central point of failure like with MQTT, but the plan is to make the central API server very lightweight - it will not even have to know what is inside packets, it will just blindly forward them to all clients that subscribed to that. Such a lightweight design will:
|
Follow up from a discord conversation.....building a mesh network would be bad. But many people clearly have a need for simple "remote switch" functionality, where they have a sensor on one microcontroller, and want to toggle a switch on another microcontroller - for example to create 2-way or 3-way switch. Only today I have seen 3 different people asking for that. |
@bruxy70 Yes... that's why this feature request exists. |
@bruxy70, afraid I'm asking for an obvious answer here but, as I was considering submitting a feature request to take advantage of native mesh networking capabilities of the ESPs (using, i.e., https://gitlab.com/painlessMesh/painlessmesh), I was hoping you'd be willing to elaborate on why mesh is bad. It seems like it would solve the resource constraints mentioned by @OttoWinter and provide an inherent level of resilience and security by removing dependency on a preexisting wifi network. |
@squirrel289, I am not going to argue with that! I still believe that the "switches" have two classes of services:
If a switch relies on ESP, WiFi, RPi, and Hassio that will definitely have the worst service availability than a simple mechanical switch. If I make an electronic switch, I can't do that without the ESP, so I'll have to accept that. But I guess this is the least likely to fail (and if it does, it will probably need to be changed anyhow). |
Why not make the mesh a feature that can be switched on when required. It can then be enabled on devices where it is required. You could also then use it as backup only when communication with the API broker is not possible |
Another idea on this is how about accomplishing this completely out of band of wifi? For example, use a 433mhz transceiver pair to do some sort of inter-device communications that has no requirement for wifi or home assistant. You could still use home assistant as a primary coordinator/relay and use a conditional check to see if it is up and then fall back to the out-of-band method of choice. (rf, bluetooth, wired i2c, etc.) To be robust, maybe two checks...one that HASS is up and another that your target device is connected. |
I think another way to do achieve this functionality would be to take advantage of the existing rest API that is exposed with the web server...
Is there a way to have a lightweight http/rest client able to make such a call from one node to another? |
@brandond - that is awesome! Thanks! |
How can I add the http_request component to my ESPHome instance? |
In my opinion mesh solutions are vastly superior to classical server/client based solutions. IoT has already been moving in that direction for a while now. It would be nice if ESPHome followed that trend. |
Did figure out how to make it work? |
I haven't yet given it a try, but if you want to what you'll need to do is use the dev branch of esphome as the http_request component has not yet been merged into the master branch. |
One thing I can't work out is if the http_request component allows for authorization? The http_server component supports digest auth, so it would be really good if we could use http_request from one ESP to control another ESP in a secure manner |
This would be very nice. My use case is a power sensor (node 1) that controls a water heater (node 2). Sending the data directly would allow for the lowest latency & significantly reduce load on Home Assistant. Has anybody succeeded in using the http_request module for this purpose? |
FWIW, Tasmota offers several options to communicate between devices. I tried each and here's my experience:
So the only disadvantage of the MQTT option is the reliance on a server, in addition to the router. I'm thus contemplating running the MQTT server on my router directly. So it seems that if ESPhome is to implement a direct communication solution that does not rely on a middle-man, its performance should be measured against MQTT. |
FWIW, @iliyang Besides all 3 options, you also have UDP groups in Tasmota. This last option could be an alternative for ESPHome for device to device communication. About KNX in Tasmota, you should open a new issue there, because KNX is pretty reliable for me. Most of the time, the initial issues some other users had with KNX were not enabling Multicast on theirs wifi routers. Anyway, UDP groups could be a light weight alternative for device to device communication on ESPHome. |
Thanks for the tips regarding KNX and UDP groups @ascillato! |
I think esp now could also be a interesting approach for ad-hoc communication between nodes. See #275 for more (and a custom_component 🎉) |
I managed to successfully use one SONOFF as the "remote" which called HTTP on the other SONOFF. Light
"Remote"
|
The way Tasmota provided this feature was through a limited set of 'Device Groups' which can be handy. |
It would be nice if switches and lights etc. could directly talk to each other. The specific use case for me is having a temp sensor directly communicate with some relays that run my air conditioner so that the air conditioner still works properly when Home Assistant is down. Perhaps one ESPHome device could add an entity from another ESPHome device using the Home Assistant native API. There could be a platform for remote ESPHome entities. YAML configuration something like this:
|
For me this is the main show stopper to move everything to ESPHome. I still use Tasmota in Sonoff RF Bridge and lamp switches that I'd like to work without Home Assistant (and during HA upgrades). For just lighting control, what about using E1.31 protocol? Client (light) side is already implemented and works fine. It is meant for a LED strips but I don't see any problem why it can't be used (or modified) to address single light(s). Only controlling code is missing. It should be quite lightweight to send UDP packets. Bigger challenge is to make this component easy to use and universal enough. Thoughts? - Sorry, I first posted it under wrong FR (#275) |
Would it be practical to break out the HA or ESPHome API broker into a standalone package for OpenWRT or a tiny Docker container? While I don't currently have the hardware to test this approach, Docker containers are supported in OpenWRT. With enough memory on the router, it's already possible to spin up a minimal HA or ESPHome container inside of OpenWRT. While perhaps not the most elegant solution, that would enable communication between nodes without a dedicated HA server. If it's feasible to take the next step and make the ESPHome (or HA) API broker run directly on OpenWRT, that would eliminate all of the Docker stuff, and perhaps allow this to work on commodity router hardware. That wouldn't be a lot different than running an MQTT broker on OpenWRT for the nodes to talk to one another, which is also already an option. But as discussed earlier, the API has advantages. |
The api is already a package/repository of its own, so that part is done. It "just" requires python3 to run, and a small number of additional requirements. Of course, you would still need to write the inter-node comms part, allowing one node to query another nodes values, or invoke a service, and at that point, you are basically running a minimal HA installation anyway. And that still doesn't address the original request: direct node-node comms, WITHOUT an intermediary. |
good question. the manual isn't completely clear to me, but for as far as I can see this is for receiving broadcast messages, not for sending them. This is a part which might be missing. |
radio comunication 433mhz transciever and reciver connected to esp chip and state comes to HA also ? |
This feature could be out of the box once esphome expands to support Thread/Zigbee on the new esp-h2 hardware. #1430 |
See https://esphome.io/cookbook/http_request_sensor.html showing how to retrieve sensor data directly from one node to another. Similarly could build up automating POST requests to toggle switches like above. |
but how to pass the authorization? |
I've added notes about that, PR is being merged. (check here until then) |
can you also link the PR for me please?
sending the plain auth header for digest gave me some issues in the past, |
It's just a PR to the docs... (2967) |
Can't we just repurpose the The same way the Like this if your ESPs have fixed ips you can easily have them talk directly to each other, without the web server overhead and super hard authentication to setup |
See: #46 |
@nagyrobi That's quite different from what I'm proposing, this issue is about creating a server in home assistant, it's still |
I don't know why he removed the other links, but #2081 is what you're looking for. |
There’s a new device group component you could try |
unfortunately I get several build errors when I try this one
Next to that, it's really cool if it would work. |
So far it’s working fine with my switches and lights. |
I still think this would be a good approach, and the security issues would be addressed by nodes sharing an API NOISE encryption key. The only snag is the use of an entity identifier in the protobuf api, rather than the actual name of the entity. While the entity identifier is derived from the name, it's not exposed anywhere obvious, making it difficult to configure the remote nodes. One way of working around that would be for nodes to do a periodic poll of "subscribed nodes", to request the entity identifier for any remote names that it has as references. This is not required with the current API because a TCP connection is torn down when the node receives a new configuration (and reboots!), while a node could easily reboot in between UDP updates without any relying nodes being any wiser. Of course, nodes could also publish relevant API messages such as DeviceInfoResponse, and ListEntitiesBinarySensorResponse on startup, telling any relying nodes to refresh any state that they are holding for entities related to that node. If I could actually code, this is what I would implement:
So a config file might look like:
|
I suspect I have missed a detail, in that the |
Tadaaaaam: esphome/esphome#6865 "Works On Everything" (TM). |
When the component linked above will be merged, this cookbook entry will be removed. |
My use would be a DIY NFC card reader with multiple protocols (including some proprietary ones, see my project) that could 'talk' to a lock controller (built on ESPhome) securely, either over network with native API or UART/RS-486. |
Remove the file, not only the link to it, as per esphome@31f188f#diff-54a294a5d016e1a8e98bc95668ed84a99a9edd5c10394d9a2b1ee848006e98a7 Related: esphome/feature-requests#52 (comment)
Is your feature request related to a problem/use-case? Please describe.
I have two EspHome nodes. One node is a wifi light bulb configured to control the light.
The other node is behind my wall switch and configured as input boolean/switch to control the light using an automation in homeassistant.
The problem is: when for some reason homeassistant is not running/responding, I can't switch the light anymore.
When the light and the switch were configured on one EspHome node I could have used an automation in EspHome to still be able to control the light.
Describe the solution you'd like:
I would love to have the possibility to create an automation in EspHome between different nodes.
Additional context:
Example:
Node1 (light):
Node2 (switch):
The text was updated successfully, but these errors were encountered: