Modbus. Need help from experts

Well can be true - only problem hard to check until spring. But can you provide more details on the possibility to interpret the data? Will test it out straight away

This is one way to interpret it, but you’d have to find what is the co-relation of the number you’re getting from the Modbus sensor, and what the real value is.

Well will try to check it. Now temperature rose to +2 and everything is back to noraml Still seems to me more like a bug in modbus sensor component of HA.
As with the calculations - will have to introduce another sensor.
Default offset will not le me handle this one

I think the best way to handle this would be to use a template sensor which interprets the data from the modbus sensor.

Well still a plus temperature so cannot get the abnormal values. Just decided to share some weird code.
Having a modbus unit everything was fine except that i had an input select for fan speeds, slider for temps and they had values like 1 to 5… So i just wanted to get it to look and feel like a climate component. Of course an ideal thing would be to write a custom component, but as my programming skills = 0 had a look around. Generic thermostat component doesn’t have fan control. Fan control doesn’t have temp settigs. So lookis like the only suitable component for an air unit in HA is MQTT HVAC.

So here is how it goes (Please don’t copy it directly as it’s only to show the logic - had to do a lot of renaming into English to show on the forum)

configuration.yaml

climate:
  - platform: mqtt
    name: Systemair
    target_sensor: sensor.rr_temperature
    initial: 15
    min_temp: 14
    max_temp: 19
    modes:
      - off
      - heat
      - fan
    fan_modes:
      - High
      - Medium
      - Low
      - Off
    power_command_topic: "systemair/set/power"
    mode_command_topic: "systemair/set/mode"
    mode_state_topic: "systemair/get/mode"
    temperature_command_topic: "systemair/set/temp"
    temperature_state_topic: "systemair/get/temp"
    fan_mode_command_topic: "systemair/set/fan"
    fan_mode_state_topic: "systemair/get/fan"
    current_temperature_topic: "systemair/current_temp"
    aux_command_topic: "systemair/set/heat"
    aux_state_topic: "systemair/get/heat"

And then some rules like

- alias: VSR Fan Set
  initial_state: 'on'
  trigger:
    - platform: mqtt
      topic: 'systemair/set/fan'
  action:
    service: modbus.write_register 
    data_template:
      unit: 1
      address: 100
      value: >
        {% if trigger.payload | string == 'Off' %}
          0
        {%-elif trigger.payload | string == 'Low' %}
          1
        {%-elif trigger.payload | string == 'High' %}
          3
        {% else %}
          2
        {% endif %}

- alias: VSR Fan Set
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: sensor.vsr_speed_on_control_panel
  action:
   - service: mqtt.publish
     data_template:
       topic: "systemair/get/fan"
       payload: >
        {% if is_state(trigger.to_state.state, "0") %}
          Off
        {%-elif is_state(trigger.to_state.state, "1") %}
          Low
        {%-elif is_state(trigger.to_state.state, "3") %}
          High
        {% else %}
          Medium
        {% endif %}       

Of course would be great to have a highly configurable HVAC component but…

Main question - how to hide the not utilised functions from climate interface? Like swing and Away_mode?

1 Like

I had the same problem as soon as temperature dropped below zero °C. Now after installing version 0.59.2 this seems to work fine.
bilde

1 Like

Hi again

Does anyone else have problems with modbus just dropping out?
Works fine for some time and then suddenly just stops communicating.
A restart of the home assistant service is enough to get it up and running again. (No reboot of the raspberry pi or other stuff.)
I’m using the adapter linked to in the start of this topic.

bilde

Example from log file:

2017-12-14 16:30:06 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.reg_hc_temp_in1 fails
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 199, in async_update_ha_state
yield from self.async_device_update()
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py”, line 306, in async_device_update
yield from self.hass.async_add_job(self.update)
File “/usr/lib/python3.5/asyncio/futures.py”, line 380, in iter
yield self # This tells Task to wait for completion.
File “/usr/lib/python3.5/asyncio/tasks.py”, line 304, in _wakeup
future.result()
File “/usr/lib/python3.5/asyncio/futures.py”, line 293, in result
raise self._exception
File “/usr/lib/python3.5/concurrent/futures/thread.py”, line 55, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/modbus.py”, line 160, in update
self._count)
File “/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/modbus.py”, line 204, in read_holding_registers
**kwargs)
File “/srv/homeassistant/lib/python3.5/site-packages/pymodbus/client/common.py”, line 109, in read_holding_registers
return self.execute(request)
File “/srv/homeassistant/lib/python3.5/site-packages/pymodbus/client/sync.py”, line 85, in execute
return self.transaction.execute(request)
File “/srv/homeassistant/lib/python3.5/site-packages/pymodbus/transaction.py”, line 140, in execute
self.client.framer.processIncomingPacket(result, self.addTransaction)
File “/srv/homeassistant/lib/python3.5/site-packages/pymodbus/transaction.py”, line 654, in processIncomingPacket
self._process(callback, error=True)
File “/srv/homeassistant/lib/python3.5/site-packages/pymodbus/transaction.py”, line 679, in _process
result = self.decoder.decode(data)
File “/srv/homeassistant/lib/python3.5/site-packages/pymodbus/factory.py”, line 223, in decode
return self._helper(message)
File “/srv/homeassistant/lib/python3.5/site-packages/pymodbus/factory.py”, line 245, in _helper
response.decode(data[1:])
File “/srv/homeassistant/lib/python3.5/site-packages/pymodbus/diag_message.py”, line 121, in decode
self.sub_function_code, self.message = struct.unpack(‘>HH’, data)
struct.error: unpack requires a bytes object of length 4

Mine is absolutely stable. Check for power consumption on USB. Had this problem with orange pi controlling my projector. USB bluetooth module dropped out. Restarting the service somehow woke it up

Hi! A question about youre modbus USB adapter. I want to do the same thing as you descripe, read temperatur from my system air ventilation. I have a modbus USB adapter. Did you add any resistance in the loop for the RS485 communication? I see in the manual from system air that it should be a 120 ohm resistance at both ends in the loops. But how is this when its onlye one master and one slave? Is it resistance in the USB adapter?

it is the end of the line so need to add it however do you have terminal connection for it?

Hi everyone!
Im thinking of implementing this control in my HA setup with our Systemair. Is it still working and is it stable?
If anyone has any advice our inputs Im happy to listen =)
Is the usb to rs485 adapter in the OP still a good choice?

I’m still using this. Stable most of the time.

Is the Systemair unit connected directly to your RPi with HA on it? Or do you send the data over WiFi to HA?

I’m thinking of connecting modbus to a Pi zero w and maybe send data with MQTT. If I can figure out how to do that :joy:

Hi all, i know how to read modbus holding registers in Home assistant from a modbus device, this is working for me. But… there is a way to write that registers from HA to modbus device? I can’t figure out how…

@gt4020 First you need a way to set the value so an input number is useful.

So in your config create something like this:

input_number:
  slider1:
    name: Irrigation Start Time
    initial: 9
    min: 4
    max: 22
    step: 1

Then you need to create an automation to write the value as the input number has a value changed something like:

- id: IrrigationStartTime
  alias: Irrigation Start Time
  trigger:
    platform: state
    entity_id: input_number.slider1
  action:
    service: modbus.write_register
    data_template:
      hub: hub3
      unit: 3
      address: 3074
      value: "{{ states.input_number.slider1.state|int }}"

Substitute your values of course…hope that helps you.

1 Like

Hi all
I have VSR300 with IAM module which can work as a modbus gateway:

image

Can anyone guide me how and where to start ? … a’ka small HowTo :slight_smile:
The only (and as much) :slight_smile: I would like to see current fans’ speeds/mode + would be great to have a possibility to set a working mode (auto,fireplace,fullspeed, holiday etc.) directly from HA.

Did you implement it?

no, not yet … noone responded so I continue with other integrations and waiting for a tips to this one.

1 Like

Hi, I followed a Norwegian guide made for HomeSeer to get up and going. I have two SystemAir units connected to Home Assistant so I may help you if you have any specific questions.

woow super :slight_smile: … The best would be to see your config how you did it :slight_smile:
I’m using IAM module which seems to have a possibility to work as Modbus Gateway.
HA have an integration with modbus but I do not know how to connect it to IAM and how to read/understand modbus codes.
I couldn’t find any complete HowTo so if you have time you could create full instruction and I believe many will appreciate it : )
Thank you very much in advance :slight_smile: