Modbus issues

following some post, I created a custom_components/modbus and I added the patched sensor.py and a copy of the init and switch file as shown in the picture below
image

but HA seems using the standard sensor components, do you know if I missed some step?

@Bard Look Here and read well…follow the instructions completely. The gist of what you are doing is you are creating a full ‘custom component’ replacement for the ‘standard’ modbus component.

OK, just got to test this as well. It works great. I can finally delete my second instance of Hass and run all in a single container. Thanks @PtP.

Here is the corrected custom_component modbus1.py:

Base your changes on existing current modbus code using @paul_c5x4 mods.

Understood? NOTE: The component is called custom_component modbus1.py

PS: Stay safe in these troubled times!

Hi @wellsy,
I’ll read today, in order to recap: I don’t need to keep the same name of the standard component, I can use a different one.
Then for use it is enough call in my config.yaml or I need to add some declaration?

Yep you got it…It MUST be a different name…it becomes a total replacement for the standard modbus integration.That means you will need to setup ALL your devices to be using that by reworking your config…fair bit of work but if done correctly it works perfectly (well it did for me in the case of the multiple hub modification).
Good luck and let us know how you go with it.

I read the post, my HA is running with hassio and I cannot figure out where get the file:

/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/modbus.py

Sorry @Bard but that is not a platform I have that sort of experience with…try searching the forum for that advice. Back when I was tinkering I messed with hassio…moved on to HA (core now?) for a few reasons.

Maybe this one could be a reason for install it in a different way :sweat_smile:, I’ll try to search a solution for an hassio config :+1:

If this is an urgent/important need then you may need to consider moving to ‘core’ as it is far more easily customizable. With a learning curve as well though.

well is not urgent, since the system is working with this issue from a long time, but my idea is to try to resolve it. Good thing of hassio that is simple to keep updated and install addon

Stick with that then…keep an eye on any posts by @paul_c5x4 for any possibility this may become a part of HA modbus. Good luck!

Hi Wellsy, I migrated my solution on HA core, I checked the procedure, but today the layout of the files is different, There is a modbus folder without any modbus.py do you know how it changed the filosofy?

Bugger…sorry since multiple hubs were introduced I have not needed to poke around so thats news to me as well. Have you looked at the modbus github repo? https://github.com/home-assistant/core/tree/dev/homeassistant/components/modbus Looks like the files I am used to seeing there mate?

modbus.py = init.py

Ok I’ll try to check again the procedure after work

1 Like

Ok I spent few days on it without a good result,
I found a different solution:
I moved all the modbus code in the node-red addon and then I transfer data using MQTT, the good thing is that with only one read, I can get all required register and then I unpacked them with a specific function

@Bard I only just noticed that you had posted this reply…good to see you have a solution you are happy with. Do you normally run Node-Red OR just for this solution?

I have used it in the past but in the interests of overall simplicity I backed away from using it.

Hi Steve,
I started with nodered in the last days, because I was looking for a solution for communicate with alexa ( I don’t want to keep port open on the router if possible) then studying it, I discovered the possibility to manage the modbus communication directly in nodered.
In my opinion is more flexible, then you can program the “function node” in javascript, so it’ss more simple manage complex code. In these days I’m moving most of the code from HA to nodered and I’ll keep in HA the “user interface” only.

Good that its been an all in one solution for you.

My appologies. I haven’t been around too much. Work has been going ballistic the last few weeks, and I’ve been playing around with setting up another HA system on a NanoPi with MQTT.
No Hassio in use (or NodeRed). so I can’t comment on “fixing” modbus issues with either of them.

1 Like

Hope I’m not hijacking the thread but can someone help out with manipulating certain flag in a 16 bit holding register? How would I go about setting 0 or 1 to bit #7 in register 201 below?

As of now I can read the register and it returns something like ‘128’. How do I come up with the value to write to this register? Thanks!