It doesn’t work because with 1 second scan_interval the various calls overlap and the server often doesn’t answer. But each answer contains the status of all sensors (eight, actually).
How to merge all these value_template in only one command_line call, that retrieve the status of the 8 sensors at once? I’m thinking about create a “virtual sensor” (a variable) that contains the answer of the server and then use it to feed the value_templates… but I’m not sure how to do with the HA components.
Great! Just a question: why you have to equal the input value to ‘0’ in sensor? It’s not enough to assign the raw value? Something like:
value_template: "{{ value[15:23] }}"
About the 0/1 question: because I prefer to use nc contacts I had to invert their logical state. I.e. when the switch is ‘off’ it actually close the input on the board to 0V.
You can assign the raw values, but then you’d need to put it in a sensor, not a binary_sensor. Binary sensors are easier to manage if the result is 1 or 0. That way when you reference the binary sensor, you can just see if its ‘on’ or ‘off’. And you can add an appropriate device_class. For example, if the 3rd one is a door, add device_class: door and it will return open/close.
The condition is always false: the string value[15:23] will never be equal to the character '0'.
Naively, I thought the value_template for the sensor should be just value[15:23], while for the binary_sensors below it’s reasonable that each one would compare the related byte.