Modbus Integer Write Out

Thanks so much to gertdb for solving this problem. I can confirm that it does resolve the issue of writing to single registers for my needs.

I edited line 63 of the file (in my case modbus2.py) as your pull request here ( https://github.com/home-assistant/home-assistant/pull/18425 ) advises.

now my line 63 reads:
vol.Required(ATTR_VALUE): vol.Any(cv.positive_int)
was:
vol.Required(ATTR_VALUE): vol.All(cv.ensure_list, [cv.positive_int])

I can also confirm that this also works if you have followed the workaround for having more than one modbus device/hub (IE: modbus1.py and modbus2.py etc). see here Ability to add multiple modbus hubs
I started with my most urgent device (using modbus2.py) to make sure this was going to work and it does so I assume all other mods of the modbus.py will behave the same. I will report back if this is not so.

You just need to remember which register you are writing to belongs to what modbus.py.

For example my automation looks like:

  • id: IrrigationStartTime
    alias: Irrigation Start Time
    trigger:
    platform: state
    entity_id: input_number.slider1
    action:
    service: modbus2.write_register
    data_template:
    unit: 3
    address: 3074
    value: “{{ states.input_number.slider1.state|int }}”

Thanks again to the whole community here and I would encourage developers to recognise that both these issues (IE: writing to registers and multiple modbus hubs) should be included into the official version at some point in the near future and that the documentation also needs to be updated.

Cheers to all!