Hello!
I’m a newbie on HA so please be patient with me
I have a rpi4 with modbus rtu hat, and a SRNE solar inverter connected + a few other sensors.
Normal holding register readings is working fine! And i have learned me the code. But i have some addresses for “state of charge”, “current fault” etc… and those addresses give a feedback in eatch bit.
Example from modbus protocoll:
Function: Holding, Address: 10B, Lenght: 1, Name: Charge State
Bits:
0x0000: Charge off
0x0001: Quick charge
0x0002: Const voltage charge
0x0003 Reserved (not in use)
0x0004: Float charge
0x0005: Reserved
0x0006: Li battery acitvate
0x0007: Reserved (not in use)
Can someone please help me with this?
I have looked around the forum but nothing i can use with my skill level.
And feel free to explain the code for me, so i can use it with other addresses to
So summarized its binary sensors inside one adress, is my tought.
And it would be nice to name them in code, so the text shows as active or not.
Here is a snip of my config, that is working:
#Modbus RTU HUB
modbus:
- name: "hub_rtu"
type: serial
method: rtu
port: /dev/ttyS0
baudrate: 9600
stopbits: 1
bytesize: 8
parity: N
delay: 5
retries: 20
retry_on_empty: true
close_comm_on_error: false
#SENSORER
#Temp inngangsmodul på RTU
sensors:
- name: "Temp modul inngang 1" # 0x0200
unique_id: 4512
slave: 4
address: 512
input_type: holding
count: 1
precision: 1
scale: 0.1
unit_of_measurement: °C
device_class: temperature
state_class: measurement
scan_interval: 10
I have tried a couple of code snippets i’ve found, but with no success.
Eks:
binary_sensor:
- platform: template
sensors:
e3dc_emergency_power_available:
friendly_name: “E3DC Emergency Power available”
value_template: “{{ states(‘sensor.Inverter_Charge_state’)|int|bitwise_and(0) > 0 }}”
Thank you in advance,
Marius