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.
@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".
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:
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.