Multiple devices using rest

I have two PLCS and am trying to use rest sensor commands to get state information. Only one PLC (the first) gets its state read…the other remains blank. I have tried this configuration:

rest:
  - resource: http://192.168.12.11/state.xml
    scan_interval: 16
    sensor:
      - name: PLC1Relay1
        value_template: "{{ value_json['datavalues']['relay1'] }}"
      - name: PLC1Relay2
        value_template: "{{ value_json['datavalues']['relay2'] }}"
      - name: PLC1Relay3
        value_template: "{{ value_json['datavalues']['relay3'] }}"
      - name: PLC1Relay4
        value_template: "{{ value_json['datavalues']['relay4'] }}"

rest:
  - resource: http://192.168.12.12/state.xml
    scan_interval: 16
    sensor:
      - name: PLC2Relay1
        value_template: "{{ value_json['datavalues']['relay1'] }}"
      - name: PLC2Relay2
        value_template: "{{ value_json['datavalues']['relay2'] }}"
      - name: PLC2Relay3
        value_template: "{{ value_json['datavalues']['relay3'] }}"
      - name: PLC2Relay4
        value_template: "{{ value_json['datavalues']['relay4'] }}"

and this

rest:
  - resource: http://192.168.12.11/state.xml
    scan_interval: 16
    sensor:
      - name: PLC1Relay1
        value_template: "{{ value_json['datavalues']['relay1'] }}"
      - name: PLC1Relay2
        value_template: "{{ value_json['datavalues']['relay2'] }}"
      - name: PLC1Relay3
        value_template: "{{ value_json['datavalues']['relay3'] }}"
      - name: PLC1Relay4
        value_template: "{{ value_json['datavalues']['relay4'] }}"

  - resource: http://192.168.12.12/state.xml
    scan_interval: 16
    sensor:
      - name: PLC2Relay1
        value_template: "{{ value_json['datavalues']['relay1'] }}"
      - name: PLC2Relay2
        value_template: "{{ value_json['datavalues']['relay2'] }}"
      - name: PLC2Relay3
        value_template: "{{ value_json['datavalues']['relay3'] }}"
      - name: PLC2Relay4
        value_template: "{{ value_json['datavalues']['relay4'] }}"

but neither work. Additionally, I am using curl GET to turn on and off the relays, but the switches still do not incorporate the state of the PLC relay so the switch slides on then off. Is there a better way to do this or a card that will incorporate both the rest state and the curl commands for on/off?

The output of my state.xml looks like this:

<datavalues>
<input1state>0</input1state>
<input2state>0</input2state>
<input3state>0</input3state>
<input4state>0</input4state>
<relay1state>0</relay1state>
<relay2state>0</relay2state>
<relay3state>0</relay3state>
<relay4state>0</relay4state>
<units>F</units>
<sensor1>x.x</sensor1>
<sensor2>x.x</sensor2>
<sensor3>x.x</sensor3>
<sensor4>x.x</sensor4>
<s1Alrm>0</s1Alrm>
<s2Alrm>0</s2Alrm>
<s3Alrm>0</s3Alrm>
<s4Alrm>0</s4Alrm>
<count1>0.000</count1>
<count2>0.000</count2>
<extvar0>0.00</extvar0>
<extvar1>0.00</extvar1>
<extvar2>0.00</extvar2>
<extvar3>0.00</extvar3>
<vin>15.879</vin>
<vinAlrm>1</vinAlrm>
<serialNumber>00:0C:C8:03:A1:30</serialNumber>
<time>1262445935</time>
</datavalues>

The second example is the correct syntax (only one rest: integration key). Your templates don’t appear to be accessing the correct keys though. There is no xml tag called “relay1”, it is “relay1state”.

Try:

value_template: "{{ value_json['datavalues']['relay1state'] }}"

Only PLC1’s relay states are being read. Even relay1 worked, but you are correct that I should change it to relay1state. Any ideas on why it is only reading PLC1?

Did you remove the second occurrence of rest: ?

Yes

est:
  - resource: http://192.168.12.11/state.xml
    scan_interval: 16
    sensor:
      - name: PLC1Relay1
        value_template: "{{ value_json['datavalues']['relay1state'] }}"
      - name: PLC1Relay2
        value_template: "{{ value_json['datavalues']['relay2state'] }}"
      - name: PLC1Relay3
        value_template: "{{ value_json['datavalues']['relay3state'] }}"
      - name: PLC1Relay4
        value_template: "{{ value_json['datavalues']['relay4state'] }}"
  
  - resource: http://192.168.12.12/state.xml
    scan_interval: 16
    sensor:
      - name: PLC2Relay1
        value_template: "{{ value_json['datavalues']['relay1state'] }}"
      - name: PLC2Relay2
        value_template: "{{ value_json['datavalues']['relay2state'] }}"
      - name: PLC2Relay3
        value_template: "{{ value_json['datavalues']['relay3state'] }}"
      - name: PLC2Relay4
        value_template: "{{ value_json['datavalues']['relay4state'] }}"

Any errors in Settings-> System-> Logs?

Template variable warning: 'dict object' has no attribute 'relay1state' when rendering '{{ value_json['datavalues']['relay1state'] }}'
2023-06-15 08:42:31.368 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay2state' when rendering '{{ value_json['datavalues']['relay2state'] }}'
2023-06-15 08:42:31.370 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay3state' when rendering '{{ value_json['datavalues']['relay3state'] }}'
2023-06-15 08:42:31.372 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'
2023-06-15 08:42:47.362 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay1state' when rendering '{{ value_json['datavalues']['relay1state'] }}'
2023-06-15 08:42:47.363 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay2state' when rendering '{{ value_json['datavalues']['relay2state'] }}'
2023-06-15 08:42:47.364 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay3state' when rendering '{{ value_json['datavalues']['relay3state'] }}'
2023-06-15 08:42:47.366 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'
2023-06-15 08:43:03.366 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay1state' when rendering '{{ value_json['datavalues']['relay1state'] }}'
2023-06-15 08:43:03.370 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay2state' when rendering '{{ value_json['datavalues']['relay2state'] }}'
2023-06-15 08:43:03.372 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay3state' when rendering '{{ value_json['datavalues']['relay3state'] }}'
2023-06-15 08:43:03.375 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'
2023-06-15 08:43:19.368 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay1state' when rendering '{{ value_json['datavalues']['relay1state'] }}'
2023-06-15 08:43:19.370 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay2state' when rendering '{{ value_json['datavalues']['relay2state'] }}'
2023-06-15 08:43:19.373 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay3state' when rendering '{{ value_json['datavalues']['relay3state'] }}'
2023-06-15 08:43:19.376 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'
2023-06-15 08:43:35.369 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay1state' when rendering '{{ value_json['datavalues']['relay1state'] }}'
2023-06-15 08:43:35.371 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay2state' when rendering '{{ value_json['datavalues']['relay2state'] }}'
2023-06-15 08:43:35.373 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay3state' when rendering '{{ value_json['datavalues']['relay3state'] }}'
2023-06-15 08:43:35.375 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'
2023-06-15 08:43:51.366 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay1state' when rendering '{{ value_json['datavalues']['relay1state'] }}'
2023-06-15 08:43:51.369 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay2state' when rendering '{{ value_json['datavalues']['relay2state'] }}'
2023-06-15 08:43:51.371 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay3state' when rendering '{{ value_json['datavalues']['relay3state'] }}'
2023-06-15 08:43:51.373 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'

Try increasing your logging level to debug to see what is going on.

logger:
  default: info
  logs:
    homeassistant.components.rest: debug

It seems to be reading both PLC’s values just fine. Perhaps it just keeps overwriting the value of the second PLC? Tried to change the intervals but nothing is written for the state of the second PLC

2023-06-15 16:28:44.134 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860923","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:28:44.134 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'
2023-06-15 16:28:44.315 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.12.11/state.xml
2023-06-15 16:28:44.329 DEBUG (MainThread) [homeassistant.components.rest] Finished fetching rest data data in 0.013 seconds (success: True)
2023-06-15 16:28:44.329 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.621</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555128</time></datavalues>
2023-06-15 16:28:44.330 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.621","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555128"}}
2023-06-15 16:28:44.330 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.621</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555128</time></datavalues>
2023-06-15 16:28:44.331 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.621","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555128"}}
2023-06-15 16:28:44.331 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.621</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555128</time></datavalues>
2023-06-15 16:28:44.332 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.621","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555128"}}
2023-06-15 16:28:44.332 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.621</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555128</time></datavalues>
2023-06-15 16:28:44.333 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.621","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555128"}}
2023-06-15 16:29:00.102 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.12.12/state.xml
2023-06-15 16:29:00.116 DEBUG (MainThread) [homeassistant.components.rest] Finished fetching rest data data in 0.015 seconds (success: True)
2023-06-15 16:29:00.117 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?>
<datavalues>
<digitalInput1>0</digitalInput1>
<digitalInput2>0</digitalInput2>
<digitalInput3>0</digitalInput3>
<digitalInput4>0</digitalInput4>
<relay1>0</relay1>
<relay2>0</relay2>
<relay3>0</relay3>
<relay4>0</relay4>
<vin>12.5</vin>
<register1>0</register1>
<oneWireSensor1>x.x</oneWireSensor1>
<oneWireSensor2>x.x</oneWireSensor2>
<oneWireSensor3>x.x</oneWireSensor3>
<oneWireSensor4>x.x</oneWireSensor4>
<utcTime>1686860939</utcTime>
<timezoneOffset>-14400</timezoneOffset>
<serialNumber>00:0C:C8:04:38:0F</serialNumber>
<downloadSettings>1</downloadSettings>
</datavalues>            
2023-06-15 16:29:00.117 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860939","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:29:00.118 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay1state' when rendering '{{ value_json['datavalues']['relay1state'] }}'
2023-06-15 16:29:00.124 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?>
<datavalues>
<digitalInput1>0</digitalInput1>
<digitalInput2>0</digitalInput2>
<digitalInput3>0</digitalInput3>
<digitalInput4>0</digitalInput4>
<relay1>0</relay1>
<relay2>0</relay2>
<relay3>0</relay3>
<relay4>0</relay4>
<vin>12.5</vin>
<register1>0</register1>
<oneWireSensor1>x.x</oneWireSensor1>
<oneWireSensor2>x.x</oneWireSensor2>
<oneWireSensor3>x.x</oneWireSensor3>
<oneWireSensor4>x.x</oneWireSensor4>
<utcTime>1686860939</utcTime>
<timezoneOffset>-14400</timezoneOffset>
<serialNumber>00:0C:C8:04:38:0F</serialNumber>
<downloadSettings>1</downloadSettings>
</datavalues>            
2023-06-15 16:29:00.125 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860939","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:29:00.125 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay2state' when rendering '{{ value_json['datavalues']['relay2state'] }}'
2023-06-15 16:29:00.130 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?>
<datavalues>
<digitalInput1>0</digitalInput1>
<digitalInput2>0</digitalInput2>
<digitalInput3>0</digitalInput3>
<digitalInput4>0</digitalInput4>
<relay1>0</relay1>
<relay2>0</relay2>
<relay3>0</relay3>
<relay4>0</relay4>
<vin>12.5</vin>
<register1>0</register1>
<oneWireSensor1>x.x</oneWireSensor1>
<oneWireSensor2>x.x</oneWireSensor2>
<oneWireSensor3>x.x</oneWireSensor3>
<oneWireSensor4>x.x</oneWireSensor4>
<utcTime>1686860939</utcTime>
<timezoneOffset>-14400</timezoneOffset>
<serialNumber>00:0C:C8:04:38:0F</serialNumber>
<downloadSettings>1</downloadSettings>
</datavalues>            
2023-06-15 16:29:00.130 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860939","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:29:00.131 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay3state' when rendering '{{ value_json['datavalues']['relay3state'] }}'
2023-06-15 16:29:00.134 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?>
<datavalues>
<digitalInput1>0</digitalInput1>
<digitalInput2>0</digitalInput2>
<digitalInput3>0</digitalInput3>
<digitalInput4>0</digitalInput4>
<relay1>0</relay1>
<relay2>0</relay2>
<relay3>0</relay3>
<relay4>0</relay4>
<vin>12.5</vin>
<register1>0</register1>
<oneWireSensor1>x.x</oneWireSensor1>
<oneWireSensor2>x.x</oneWireSensor2>
<oneWireSensor3>x.x</oneWireSensor3>
<oneWireSensor4>x.x</oneWireSensor4>
<utcTime>1686860939</utcTime>
<timezoneOffset>-14400</timezoneOffset>
<serialNumber>00:0C:C8:04:38:0F</serialNumber>
<downloadSettings>1</downloadSettings>
</datavalues>            
2023-06-15 16:29:00.135 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860939","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:29:00.135 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'
2023-06-15 16:29:00.315 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.12.11/state.xml
2023-06-15 16:29:00.321 DEBUG (MainThread) [homeassistant.components.rest] Finished fetching rest data data in 0.006 seconds (success: True)
2023-06-15 16:29:00.321 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.621</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555144</time></datavalues>
2023-06-15 16:29:00.321 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.621","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555144"}}
2023-06-15 16:29:00.322 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.621</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555144</time></datavalues>
2023-06-15 16:29:00.322 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.621","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555144"}}
2023-06-15 16:29:00.322 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.621</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555144</time></datavalues>
2023-06-15 16:29:00.322 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.621","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555144"}}
2023-06-15 16:29:00.322 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.621</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555144</time></datavalues>
2023-06-15 16:29:00.322 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.621","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555144"}}
2023-06-15 16:29:13.578 INFO (SyncWorker_8) [homeassistant.components.command_line] Running state code command: curl -k http://192.168.12.11:7614/state.xml
2023-06-15 16:29:16.102 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.12.12/state.xml
2023-06-15 16:29:16.113 DEBUG (MainThread) [homeassistant.components.rest] Finished fetching rest data data in 0.011 seconds (success: True)
2023-06-15 16:29:16.113 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?>
<datavalues>
<digitalInput1>0</digitalInput1>
<digitalInput2>0</digitalInput2>
<digitalInput3>0</digitalInput3>
<digitalInput4>0</digitalInput4>
<relay1>0</relay1>
<relay2>0</relay2>
<relay3>0</relay3>
<relay4>0</relay4>
<vin>12.5</vin>
<register1>0</register1>
<oneWireSensor1>x.x</oneWireSensor1>
<oneWireSensor2>x.x</oneWireSensor2>
<oneWireSensor3>x.x</oneWireSensor3>
<oneWireSensor4>x.x</oneWireSensor4>
<utcTime>1686860955</utcTime>
<timezoneOffset>-14400</timezoneOffset>
<serialNumber>00:0C:C8:04:38:0F</serialNumber>
<downloadSettings>1</downloadSettings>
</datavalues>            
2023-06-15 16:29:16.114 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860955","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:29:16.114 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay1state' when rendering '{{ value_json['datavalues']['relay1state'] }}'
2023-06-15 16:29:16.116 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?>
<datavalues>
<digitalInput1>0</digitalInput1>
<digitalInput2>0</digitalInput2>
<digitalInput3>0</digitalInput3>
<digitalInput4>0</digitalInput4>
<relay1>0</relay1>
<relay2>0</relay2>
<relay3>0</relay3>
<relay4>0</relay4>
<vin>12.5</vin>
<register1>0</register1>
<oneWireSensor1>x.x</oneWireSensor1>
<oneWireSensor2>x.x</oneWireSensor2>
<oneWireSensor3>x.x</oneWireSensor3>
<oneWireSensor4>x.x</oneWireSensor4>
<utcTime>1686860955</utcTime>
<timezoneOffset>-14400</timezoneOffset>
<serialNumber>00:0C:C8:04:38:0F</serialNumber>
<downloadSettings>1</downloadSettings>
</datavalues>            
2023-06-15 16:29:16.116 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860955","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:29:16.117 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay2state' when rendering '{{ value_json['datavalues']['relay2state'] }}'
2023-06-15 16:29:16.119 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?>
<datavalues>
<digitalInput1>0</digitalInput1>
<digitalInput2>0</digitalInput2>
<digitalInput3>0</digitalInput3>
<digitalInput4>0</digitalInput4>
<relay1>0</relay1>
<relay2>0</relay2>
<relay3>0</relay3>
<relay4>0</relay4>
<vin>12.5</vin>
<register1>0</register1>
<oneWireSensor1>x.x</oneWireSensor1>
<oneWireSensor2>x.x</oneWireSensor2>
<oneWireSensor3>x.x</oneWireSensor3>
<oneWireSensor4>x.x</oneWireSensor4>
<utcTime>1686860955</utcTime>
<timezoneOffset>-14400</timezoneOffset>
<serialNumber>00:0C:C8:04:38:0F</serialNumber>
<downloadSettings>1</downloadSettings>
</datavalues>            
2023-06-15 16:29:16.119 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860955","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:29:16.120 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay3state' when rendering '{{ value_json['datavalues']['relay3state'] }}'
2023-06-15 16:29:16.121 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?>
<datavalues>
<digitalInput1>0</digitalInput1>
<digitalInput2>0</digitalInput2>
<digitalInput3>0</digitalInput3>
<digitalInput4>0</digitalInput4>
<relay1>0</relay1>
<relay2>0</relay2>
<relay3>0</relay3>
<relay4>0</relay4>
<vin>12.5</vin>
<register1>0</register1>
<oneWireSensor1>x.x</oneWireSensor1>
<oneWireSensor2>x.x</oneWireSensor2>
<oneWireSensor3>x.x</oneWireSensor3>
<oneWireSensor4>x.x</oneWireSensor4>
<utcTime>1686860955</utcTime>
<timezoneOffset>-14400</timezoneOffset>
<serialNumber>00:0C:C8:04:38:0F</serialNumber>
<downloadSettings>1</downloadSettings>
</datavalues>            
2023-06-15 16:29:16.121 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860955","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:29:16.121 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'
2023-06-15 16:29:16.316 DEBUG (MainThread) [homeassistant.components.rest.data] Updating from http://192.168.12.11/state.xml
2023-06-15 16:29:16.327 DEBUG (MainThread) [homeassistant.components.rest] Finished fetching rest data data in 0.011 seconds (success: True)
2023-06-15 16:29:16.327 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.569</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555160</time></datavalues>
2023-06-15 16:29:16.328 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.569","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555160"}}
2023-06-15 16:29:16.328 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.569</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555160</time></datavalues>
2023-06-15 16:29:16.329 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.569","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555160"}}
2023-06-15 16:29:16.329 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.569</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555160</time></datavalues>
2023-06-15 16:29:16.330 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.569","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555160"}}
2023-06-15 16:29:16.330 DEBUG (MainThread) [homeassistant.components.rest.sensor] Data fetched from resource: <?xml version="1.0" encoding="utf-8" ?><datavalues><input1state>0</input1state><input2state>0</input2state><input3state>0</input3state><input4state>0</input4state><relay1state>0</relay1state><relay2state>0</relay2state><relay3state>0</relay3state><relay4state>0</relay4state><units>F</units><sensor1>x.x</sensor1><sensor2>x.x</sensor2><sensor3>x.x</sensor3><sensor4>x.x</sensor4><s1Alrm>0</s1Alrm><s2Alrm>0</s2Alrm><s3Alrm>0</s3Alrm><s4Alrm>0</s4Alrm><count1>0.000</count1><count2>0.000</count2><extvar0>0.00</extvar0><extvar1>0.00</extvar1><extvar2>0.00</extvar2><extvar3>0.00</extvar3><vin>15.569</vin><vinAlrm>1</vinAlrm><serialNumber>00:0C:C8:03:A1:30</serialNumber><time>1262555160</time></datavalues>
2023-06-15 16:29:16.330 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"input1state":"0","input2state":"0","input3state":"0","input4state":"0","relay1state":"0","relay2state":"0","relay3state":"0","relay4state":"0","units":"F","sensor1":"x.x","sensor2":"x.x","sensor3":"x.x","sensor4":"x.x","s1Alrm":"0","s2Alrm":"0","s3Alrm":"0","s4Alrm":"0","count1":"0.000","count2":"0.000","extvar0":"0.00","extvar1":"0.00","extvar2":"0.00","extvar3":"0.00","vin":"15.569","vinAlrm":"1","serialNumber":"00:0C:C8:03:A1:30","time":"1262555160"}}

Have a close look at the error message:

2023-06-15 16:28:44.134 DEBUG (MainThread) [homeassistant.components.rest.sensor] JSON converted from XML: {"datavalues":{"digitalInput1":"0","digitalInput2":"0","digitalInput3":"0","digitalInput4":"0","relay1":"0","relay2":"0","relay3":"0","relay4":"0","vin":"12.5","register1":"0","oneWireSensor1":"x.x","oneWireSensor2":"x.x","oneWireSensor3":"x.x","oneWireSensor4":"x.x","utcTime":"1686860923","timezoneOffset":"-14400","serialNumber":"00:0C:C8:04:38:0F","downloadSettings":"1"}}
2023-06-15 16:28:44.134 WARNING (MainThread) [homeassistant.helpers.template] Template variable warning: 'dict object' has no attribute 'relay4state' when rendering '{{ value_json['datavalues']['relay4state'] }}'

It’s complaining about a missing relay4state and it’s right: there isn’t one. This response contains relay4 not relay4state. Have a careful look at the XML response from each PLC and see what keys it actually contains.

So PLC2 is not returning the same xml tags as PLC1. Try this:

rest:
  - resource: http://192.168.12.11/state.xml
    scan_interval: 16
    sensor:
      - name: PLC1Relay1
        value_template: "{{ value_json['datavalues']['relay1state'] }}"
      - name: PLC1Relay2
        value_template: "{{ value_json['datavalues']['relay2state'] }}"
      - name: PLC1Relay3
        value_template: "{{ value_json['datavalues']['relay3state'] }}"
      - name: PLC1Relay4
        value_template: "{{ value_json['datavalues']['relay4state'] }}"
  
  - resource: http://192.168.12.12/state.xml
    scan_interval: 16
    sensor:
      - name: PLC2Relay1
        value_template: "{{ value_json['datavalues']['relay1'] }}"
      - name: PLC2Relay2
        value_template: "{{ value_json['datavalues']['relay2'] }}"
      - name: PLC2Relay3
        value_template: "{{ value_json['datavalues']['relay3'] }}"
      - name: PLC2Relay4
        value_template: "{{ value_json['datavalues']['relay4'] }}"

Oh geez…you are very, very right! I should have looked closer (I think I saw the same formatted output ans naturally assumed the same manufacturer would use same names for different models) and thank you for pointing this out.