Hello, new user here.
I am having problems with uint32 type.
I read a value from modbus tcp. The value is obtained like this:
# Futura modbus
modbus:
- name: "futura"
type: tcp
host: 192.168.88.6
port: 502
sensors:
- name: fut_mode
address: 16
count: 2
data_type: uint32
The “fut_mode” is a status variable, containing 22 bits, every bit has a certain meaning. As you can see, it is located in two adresses (16 and 17) in the modbus, therefore, I have to read count:2
This returns the value:
fut_mode = 16777216
which means the bit number 8 is active 00000001 00000000 00000000 00000000
Now, the problem I am facing is to create a binary sensor using Templates to present this status bit.
This is my code:
# Futura binary signals
template:
- binary_sensor:
- name: fut_mode_bit_08
state: "{{ int(sensor.fut_mode)|bitwise_and(16777216) != 0 }}"
For some reason, this does’t work.
I suspect it has something to do with the uint32 type, because when I this into dev tools - templates:
{% set sensor = {
"fut_mode": "16777216"
} %}
{{ int(sensor.fut_mode) }}
{{ int(sensor.fut_mode)|bitwise_and(16777216) != 0 }}
it is working ok and returning 16777216 and True
But in the above configuration.yaml, it is showing the fut_mode_bit_08 as unavailable
Any help?
Thanks