Restful sensor mistery

Hello, my first question, hopefully I’ll do everything right :slight_smile:

Context: I’m trying to get the information out of a VZUG tumbler to drive some lights to know the status.

From a terminal in VS Code connected to remote HA Server, I can run the following successfully:

sudo curl -s http://192.168.20.51/ai\?command\=getDeviceStatuscurl

and the results I got depending on the timing were:

{"DeviceName":"","Serial":"12011 XXXXXX","Inactive":"true","Program":"","Status":"","ProgramEnd":{"End":"","EndType":"0"}}
{"DeviceName":"","Serial":"12011 XXXXXX","Inactive":"false","Program":"Mangelfeucht","Status":"Beladungsmessung\n","ProgramEnd":{"End":"1h35","EndType":"2"}}
{"DeviceName":"","Serial":"12011 XXXXXX","Inactive":"false","Program":"Mangelfeucht","Status":"Trocknen\nTrockengrad Mangelfeucht","ProgramEnd":{"End":"0h03","EndType":"2"}}
{"DeviceName":"","Serial":"12011 XXXXXX","Inactive":"false","Program":"Mangelfeucht","Status":"Programmende (Türsieb reinigen)\nEcoManagement  0,1 kWh","ProgramEnd":{"End":"","EndType":"0"}}

Good starting I thought, integration works; now it is time to create a restful sensor to see something on dashboard.
Again through VS Code I added the following to the configuration.yaml:

sensor:
  - platform: rest
    unique_id: ff75d0d46a6c4c799c6c21bfd4e6f179
    name: Tumbler 
    resource: http://192.168.20.51/ai\?command\=getDeviceStatus
    value_template: "{{ value_json.Inactive }}"
    json_attributes:
      - Inactive
      - Program
      - Status

But this is what I get in the dashboard:
immagine
and if I check in Dev Tools - States, I can get nothing again:

I tried to go to template editor, adding this:


{% set value_json = {"DeviceName":"","Serial":"12011 XXXXXX","Inactive":"true","Program":"","Status":"","ProgramEnd":{"End":"","EndType":"0"}} %}
{{ value_json.Serial }}
{{ not value_json.Inactive }}

and result is as expected:
immagine

for the value template, just to try everything, I made many attempts:

    value_template: "{{ value_json.Inactive }}"
    value_template: "{{ value_json.inactive }}"
    value_template: "{{ value_json[Inactive] }}"
    value_template: "{{ value_json[inactive] }}"
    value_template: "{{ value_json['Inactive'] }}"
    value_template: "{{ value_json['inactive'] }}"

but none of them solved the issue.

Could someone please help me pointing me in the right direction to find what I am doing wrong?

Thanks :slight_smile:

Seem OK to me but…the name of the sensor you defined above is “Tumbler”, not "Tumbler Adora V2000 " and not “rest_sensor”. Did you misalign above or are you looking at the wrong sensor
For any further self-work do add logging on rest to your configuration.yaml

Did you try without the backslash, i.e. http://192.168.20.51/ai?command=getDeviceStatus
It seems suspiscious

I did so many attempts and screenshots have been taken at different times, but to be sure I rewrote it from scratch, as explained in following answer

That looked primising, but no luck, still the same

Oh there are 2 actually. Did you remove both? (edited my original response)

Following above suggestions I rewrote the sensor inb the following way, but still with no luck:

sensor:
  - platform: rest
    name: VZUG Tumbler
    json_attributes:
      - Inactive
      - Program
      - Status
    resource: http://192.168.20.51/ai\?command=getDeviceStatus
    value_template: "{{ value_json.Inactive }}"
  - platform: template
    sensors:
      inactive:
        friendly_name: "Inactive"
        value_template: "{{ state_attr('sensor.vzug_tumbler', 'Inactive') }}"
      program:
        friendly_name: "Program"
        value_template: "{{ state_attr('sensor.vzug_tumbler', 'Program') }}"
      status:
        friendly_name: "Status"
        value_template: "{{ state_attr('sensor.vzug_tumbler', 'Status') }}"        

result:
immagine

Great, thanks, that was the issue, working “curl” drove me wrong direction
Kudos to you

this is right code:

sensor:
  - platform: rest
    name: VZUG Tumbler
    json_attributes:
      - Inactive
      - Program
      - Status
    resource: http://192.168.20.51/ai?command=getDeviceStatus
    value_template: "{{ value_json.Serial }}"
  - platform: template
    sensors:
      inactive:
        friendly_name: "Inactive"
        value_template: "{{ state_attr('sensor.vzug_tumbler', 'Inactive') }}"
      program:
        friendly_name: "Program"
        value_template: "{{ state_attr('sensor.vzug_tumbler', 'Program') }}"
      status:
        friendly_name: "Status"
        value_template: "{{ state_attr('sensor.vzug_tumbler', 'Status') }}"        
1 Like