14yannick / HCPBridgeMqtt

emulates Hoermann HAP 1 HCP (HCP2) on ESP8622, ESP32 and Arduino.
1 stars 0 forks source link

Considerd moving to Esphome external component? #8

Closed jkaberg closed 8 months ago

jkaberg commented 1 year ago

Hey @14yannick, you seem like one of the few active devs working on this so thought I'd reach out to you and ask.

Would you consider moving the previous work done here over to work in tandem with Esphome's external components? There's an good implementation over here as reference

There's lots of benefits with using Esphome from an user perspective

I think the biggest upside with using Esphome is that one can focus developing the "crucial parts" instead of wifi, mqtt etc as these parts are already handled by the community :-)

14yannick commented 1 year ago

Hi @jkaberg, thanks for your interest. I like the idea of using a framework like esphome. My programming skills will not be sufficient to port this project to esphome. Maybe if we can find someone creating the interface I will be able to implement it. Do you have another implementation as reference maybe a smaller one because the one you share looks quite massif.

jkaberg commented 1 year ago

@14yannick the official dev has a few example components which might be a good starting point? It also has some documentation describing how it works

https://github.com/jesserockz/esphome-external-component-examples

There's a few to look at here: https://github.com/jesserockz/esphome-external-component-examples/tree/master/custom_components

I'm by no means any C++ guy, and so-so Python wise so I might be able to help with the Python part (interface)

14yannick commented 1 year ago

Hi @jkaberg and @BradleyFord, I just make some try to get the code working in the esphome framework. I have try the template method and the custom cover. Both resulting in the same for the moment. As soon I send a command the motor move for a fraction of a second then stop showing error 7. https://github.com/14yannick/HCPBridgeMqtt/tree/NOT_Working_esphome/esphome Maybe you and Bradley can have a look maybe I'm doing some obvious error. What is the best practice in Esphome working with template or custom components?

jkaberg commented 1 year ago

@14yannick That's great news! Unfortunately I'm away on vacation for a couple of weeks and won't be able look into this currently

kfroeschl commented 1 year ago

Hi,

As for ESP-Home. I've tried that as well - with no success.

From my understanding ESP-Home basically writes the application code for you and put's it together. This makes a lot of things easier but are restrictive in some ways as well.

The original implementation relied on the HCP/Modbus communication to run in a separate Thread (xTaskCreatePinnedToCore).

If this is not the case and at any point the Modbus communication fails to respond the Hoermann Engine will stop sending Messages overall. (Error 7)

I would also avoid sending any messages in the Modbus Thread since it may block the communication an can lead to bus shutdown.

jkaberg commented 1 year ago

perhaps @jesserockz has some good pointers on how we should proceed here?

jkaberg commented 1 year ago

IDK if there is any interest but Esphome updated their documentation to better explain how custom components work and how to register one, see links:

https://esphome.io/components/sensor/custom https://esphome.io/components/cover/custom https://esphome.io/custom/custom_component.html

14yannick commented 1 year ago

I think the main issue is that the garage door need a modbus connection which cannot be interrupted. It's way in the project we use a dual core ESP32 with one core dedicated to the modbus communication. I haven't see a way telling to the esphome framework only to work on a single core leaving the other for the modbus. I have ordered some component to try a different approach. A device who only interacting with the motor with a second ESP to interact with the other chip.

jkaberg commented 1 year ago

@14yannick this PR implements ModbusRTU in Esphome, would that help? I was thinking perhaps one could base an implementation on that

14yannick commented 8 months ago

I close this as mapero has done the job. https://github.com/mapero/esphome-hcpbridge