Hi,
I did not find anything on how to read the values from the moxa ioLogik e1214 via modbus. As I was only interested in the status of the dry contact DI ports the example only covers those. I added this config to my config.yaml. I hope this helps .
May thanks to Nythbran23 as his example helped me to create this config (Extracting Binary state of bits from Modbus uint16 holding register - #2 by Nythbran23)
modbus:
- name: MoxaIO
type: tcp
host: 192.168.178.172
port: 502
sensors:
- name: MoxaIO_DI
unique_id: MoxaIO_DI_1
address: 48
scan_interval: 5
data_type: custom
input_type: input
count: 1
structure: ">H"
slave: 1
state_class: measurement
template:
- sensor:
- name: "Moxa_DI_Value_Map"
state: "{{ states('sensor.MoxaIO_DI') }}"
attributes:
Moxa_D0: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(1) %}on{% else %}off{% endif %}"
Moxa_D1: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(2) %}on{% else %}off{% endif %}"
Moxa_D2: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(4) %}on{% else %}off{% endif %}"
Moxa_D3: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(8) %}on{% else %}off{% endif %}"
Moxa_D4: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(16) %}on{% else %}off{% endif %}"
Moxa_D5: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(32) %}on{% else %}off{% endif %}"
- binary_sensor:
- name: Moxa_D0
state: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(1) %}on{% else %}off{% endif %}"
unique_id: Moxa_TBDIB1075382_D1
- binary_sensor:
- name: Moxa_D1
state: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(2) %}on{% else %}off{% endif %}"
unique_id: Moxa_TBDIB1075382_D2
- binary_sensor:
- name: Moxa_D2
state: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(4) %}on{% else %}off{% endif %}"
unique_id: Moxa_TBDIB1075382_D3
- binary_sensor:
- name: Moxa_D3
state: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(8) %}on{% else %}off{% endif %}"
unique_id: Moxa_TBDIB1075382_D4
- binary_sensor:
- name: Moxa_D4
state: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(16) %}on{% else %}off{% endif %}"
unique_id: Moxa_TBDIB1075382_D5
- binary_sensor:
- name: Moxa_D5
state: "{% if states('sensor.MoxaIO_DI') | int | bitwise_and(32) %}on{% else %}off{% endif %}"
unique_id: Moxa_TBDIB1075382_D6