Hi everybody,
I may have missed something, so please correct me.
I want to run a list of actions on an ESP device directly from another device. Right now I see only two common possibilities for creating named actions: scripts and API services. Both are pretty cool in different cases, but there is no way to call them between devices.
API user-defined services seem the most suitable object in my case, because they are already shared with homeassistant server with Native API. Unfortunately, I didn’t find a simple solution to call Native API methods from one ESP to another.
Now I’m thinking to add user-defined API services to Web server API. I’d be glad to hear community comments/suggestions on that. I’m not a skilled CPP programmer, but have a lot of excitement to dive into the code.
I would probably look into the RESTful interface of the Web Server Component and then use a HTTP Request to access that RESTful interface from another ESP.
Only problem is that the Web Server Component is quite big.
Edit: found this also: esphome-docs/cookbook/http_request_sensor.rst at 359ce8c896e4e1672bf3717b89538567af381429 · esphome/esphome-docs · GitHub
You cant direct communicate between 2 nodes with native api, thats for communication with HA. You can use HA as a middleman(Native api) or if you’re using esp32 you could use BT between them, or the only other way is use Event Source Web API or REST API.
There’s physical connections too… uart/serial
@WallyR Yes, I exactly look into Web Server API, but it can’t trigger a certain “function”(script or service) with parameters. The only way I see, to create a custom template component with parameters: number, fan, light, cover. Then use it as a function’s trigger. It looks weird like shaving with a lawnmower. That’s why I’m ready to invest some time to make RPC call possible with REST Web server API
@Fallingaway24 Agreed. I also thought about UART, but now what to reduce wires. I don’t like to use HA for inter-communication, because it’s not stable enough, just another point of failure. REST/Event Source unfortunately don’t support calling a function.
That’s why I’m asking If somebody had a plan to add user-defined services to REST API. Or add support for Native API client.
I have not worked with the REST interface in ESPHome, but you might have the option to PUT/POST values before calling the function.
It will be multiple calls, but should work.
I understand wanting redundancies in the eveng HA has a problem and I plan for that too by putting most automations on esp boards. What i dont understand is why you dont want to use HA as the middleman but your trying to direct communicate from 1 node to another for the purpose of triggering user defined services.
User defined services are meant to be made in esphome and triggered from HA. Its essentially an esphome automation that is triggered from HA…
Why not instead of using User defined services, just use regular automations on the esphome device and then you can trigger those through a POST request from any node.
Another option would be to upgrade whatever hardware is causing instability issues with your HA. Thats not normal and the 3+ years ive used it, it has actually been very stable and reliable.
@Fallingaway24 My setup is mostly about plants light+irrigation+fertilization. It should be as fault-tolerant as possible. I have a lot of issues with HA, because it is very complex system. I already updated the hardware, build my custom set of tools. The last was in the beginning of the year, when my system was updated. Of course, I can fix the versions, setup watchdogs, health checkers and etc. But the right way is to build the simplest communication. HA is not an RDBS or RabbitMQ, it doesn’t guarantee anything. That’s why I will use i2c in many cases, but HTTP RPC will be also usable.
One more reason to avoid using HA as middleware, is blurring of responsibility of the code between HA and ESPHome files. YAML programming also hurts me(
Oh, that makes sense. I worked in the green industry for 15 years and i understand the risk of water or fertilizer automations failing. Something to keep in mind for the future is you can ways set up redundancy automations. A redundancy automation that checks to see if something should be on/off and corrects it if theres a problem.
Yes, I think so. I definitely miss native redundancy possibilities in HA as well as well-deigned automations programming language with better DRY abilities and unit-testing support.
It is not redundancy that is being suggested, but rather sensibility checks of states of your environment that can be used to catch failures.
Oh, I took some time to study my approach. Unfortunately, custom services are too coupled to the Native API and Protobuff messages. But scripts do not have a repository, and are created as root objects. So I don’t think I’m ready to bring a layer of abstraction and inversion of control there. Since I already found another (implicit) solution to my problem, I won’t bother improving the code. Let this remain for seekers: the issue of simple interaction between devices in the ESPHome has not yet been resolved, and is being discussed in many threads. Custom services and scripts partially duplicate each other’s functionality, but solve completely different problems. In my opinion, they can be unified, but more context is needed