REST sensors and commands stopped working

Hi all.

Earlier this year I used rest and rest_command in the config file in order to manage some alcohol fireplaces I bought. I discovered that the fireplaces exposed unauthenticated HTTP endpoints that I could use to get their status and control their functions (flame on/off, flame height, etc.).

My configuration worked perfectly…until it all stopped a while (couple months?) back — I’m assuming after a HA update because I haven’t touched configuration.yaml in ages.

Does anyone have any idea what might have changed?

Here is the relevant portion of configuration.yaml:

# RESTful sensor and service integration for Planika fireplaces
rest: !include rest.yaml
rest_command: !include rest_command.yaml

And rest.yaml:

- scan_interval: 15
  resource: http://192.168.1.87/state.xml
  sensor:
    - name: "living_room_fireplace_name"
      value_template: "{{ value_json['params']['param'][0]['value'] }}"
      json_attributes_path: $.params.param[0]
      json_attributes:
        - value
    - name: "living_room_fireplace_fuel_level"
      value_template: "{{ value_json['params']['param'][2]['value'] }}"
      json_attributes_path: $.params.param[2]
      json_attributes:
        - value
    - name: "living_room_fireplace_flame_level"
      value_template: "{{ value_json['params']['param'][3]['value'] }}"
      json_attributes_path: $.params.param[3]
      json_attributes:
        - value
    - name: "living_room_fireplace_status"
      json_attributes_path: $.params.param[4]
      json_attributes:
        - value
      value_template: >
        {% set tryb = value_json['params']['param'][4]['value'] | int %}
        {% if tryb == 1 %}ready
        {% elif tryb == 2 %}heating
        {% elif tryb == 5 %}fuel_empty
        {% elif tryb == 9 %}cooling
        {% elif tryb == 20 %}on
        {% elif tryb == 253 %}off
        {% else %}unknown
        {% endif %}

Finally, rest_command.yaml:

living_room_fireplace_on:
  url: "http://192.168.1.87/No_content"
  method: post
  content_type: "application/x-www-form-urlencoded"
  payload: "__SL_P_UBT=ButtonStart"
living_room_fireplace_off:
  url: "http://192.168.1.87/No_content"
  method: post
  content_type: "application/x-www-form-urlencoded"
  payload: "__SL_P_UBT=ButtonStop"
living_room_fireplace_flame_up:
  url: "http://192.168.1.87/No_content"
  method: post
  content_type: "application/x-www-form-urlencoded"
  payload: "__SL_P_UBT=ButtonPlus"
living_room_fireplace_flame_down:
  url: "http://192.168.1.87/No_content"
  method: post
  content_type: "application/x-www-form-urlencoded"
  payload: "__SL_P_UBT=ButtonMinus"

Sorry no one replied. I found your post because I too am having JSON problems. Its worked for months and during the past week or so it stop without me changing the source Code. I have 3 internal websites that I went to trouble of coding them JSON because it seemed like the right thing to do, but now its seems like Its crippling my ability to watch the data they produce. My other sites on my internal network that post plain text are working fine. Scouring this board and the internet for days with no solution. I’ve whittled down the code to just as simple as I can get it and it still doesnt work. Very much feeling like some of the updates done over the past few days at the end of the year broke something - but dang if I can figure out what it is. The JSON works fine in the Template tool.

- platform: rest
  resource: http://192.168.0.232/voltage.json
  value_template: '{{value_json.Power}}'

JSON from the website

{
"Load Voltage": " 4.076 V",
"Current": " 0.001 A",
"Power": " 0.006 W",
"Percent": "89.7%",
"Time":       " 2024-01-08 18:35:02 "
}

If i could spare any hair- I’d have pulled it out already.

1 Like

@ablock Is there anything in your logs? Are you sure the fireplace is still on .87 and hasn’t been given another address by DHCP? Can you post the output of this terminal command:

curl http://192.168.1.87/state.xml

@dustball62 Is that the entirety of your sensor config? If you have unit_of_measurement: 'W' or device_class: power assigned to it, recent updates won’t allow a state of " 0.006 W".

Thank you for taking the time to look at this.

Yes that is the entirety of the of the configuration. I had started out with more kept chopping off stuff until there was no fluff left. This one was a new one I was trying to set up.

The existing one stopped working a few days earlier and I figured if I found out this issue with the new one I could fix the old one.

The old one was a little more complex with the raw JSON data:

{"free_space":"651264","rx_id":"70","tx_id":"242","tx_rssi":"-118","rx_rssi":"-52","firmware_version":"214","hardware_version":"4","id":"083A8DE64517","ip":"192.168.0.135","subnet":"255.255.255.0","gateway":"192.168.0.1","dns":"unknown","tx_firmware_version":"18","tx_hardware_version":"16","fails":"111","rx_sensors":"[]","tx_sensors":"[{\"1\":14910,\"z\":10246},{\"3\":30.0},{\"2\":6.60}]"}

and the Yaml sensor:

- platform: rest
  name: mainwatertank
  resource: http://192.168.0.135/config?json=true
  scan_interval: 300
  value_template: '{{ ((value_json.tx_sensors | regex_findall_index("1\":(-?\d+\.?\d+)") | float() / 102.46)  | float() -100 ) | round(2) }}'
  unit_of_measurement: "%"

which had worked for months until the end of December. There was what seemed to be a flood of updates near the end of the year, so I’m thinking something changed and I didnt catch it.
hopefully someone will tell me what’s changed. Meanwhile I’ll keep beating my head against the wall until something gives.

Thanks for your response, @Troon. As it happens, I didn’t look at this for a few days and just saw your post. I went to check on it, and the entities are working again.

So :person_shrugging:, I guess.