Hi, be patient I’m a newbie
Already I read the registers of my inverter successfully. But there are registers concerning fault that I’ not capable to read.
This is sensor that read Fault1:
Also found an example of someone adding attributes to the original sensor
- sensor:
- name: "Modbus_ZCS_Inverter_all_data"
state: "{{ states(‘sensor.Modbus_ZCS_Inverter_some_sensor') }}"
attributes:
grip_ovp: "{% if states('sensor.Modbus_ZCS_Inverter_Fault_1') | int | bitwise_and(1) %}true{% else %}false{% endif %}"
grid_uvp: "{% if states('sensor.Modbus_ZCS_Inverter_Fault_1') | int | bitwise_and(2) %}true{% else %}false{% endif %}"
grid_ofp: "{% if states('sensor.Modbus_ZCS_Inverter_Fault_1') | int | bitwise_and(4) %}true{% else %}false{% endif %}"
grid_ufp: "{% if states('sensor.Modbus_ZCS_Inverter_Fault_1') | int | bitwise_and(8) %}true{% else %}false{% endif %}"
etc
This uses some ‘other sensor’ from your ZCS inverter, copies its state and adds the faults as attributes, so everything stays neatly in one sensor
(note that it might be a bit easier to use a sensor instead of a binary_sensor, it is a bit more flexible )
It seems in the template editor works fine. I’ve created a zcs_fault.yaml in packages and paste the code in:
- sensor:
- name: zcs_faults
state: "{{ states('sensor.ZCS_Inverter_faults') }}"
attributes:
grip_ovp: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(1) %}true{%
else %}false{% endif %}"
grid_uvp: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(2) %}true{%
else %}false{% endif %}"
grid_ofp: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(4) %}true{%
else %}false{% endif %}"
grid_ufp: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(8) %}true{%
else %}false{% endif %}"
island_fault: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(128) %}true{%
else %}false{% endif %}"
in check configuration get: expected a dictionary for dictionary value @ data[‘packages’][‘zcs_fault’]
Where am I wrong?
Also, in this way I read the first 4 bits of byte 0 of the table above. If I wanted to read the bits of byte 1 of the table what should I change in the code?
Please be patient, I’m no expert and would also like to understand what the code says.
You are trying to add attributes to sensor.ZCS_Inverter_faults.
However, there it is not created in the modbus sensors…
You need to add it to an existing sensor…
so try this:
this will create a new sensor.zcs_inverter, which will have the (copied) status from sensor.modbus_ZCS_Temperatura_Inverter and faults as attributes from sensor.ZCS_Fault_1
Ok I added attributes to an existing sensor in the modbus sensors
- sensor:
- name: zcs_faults
state: "{{ states('sensor.Modbus_ZCS_Voltaggio_Rete') }}"
attributes:
grip_ovp: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(1) %}true{%
else %}false{% endif %}"
grid_uvp: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(2) %}true{%
else %}false{% endif %}"
grid_ofp: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(4) %}true{%
else %}false{% endif %}"
grid_ufp: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(8) %}true{%
else %}false{% endif %}"
island_fault: "{% if states('sensor.ZCS_Fault_1') | int | bitwise_and(128) %}true{%
else %}false{% endif %}"
and I get new sensor zcs_fault with state of the existing sensor plus new attributes
But when I check configuration I get “expected a dictionary for dictionary value @ data[‘packages’][‘zcs_fault’]”
I have a feeling it has to do with the zcs_fault.yaml file in packages folder but i don’t understand how. Do you have an idea?
Sorry, I forgot “template:”