RESTful binary sensor doesn't recognize 1 as on

My RESTful binary sensor doesn’t show as on, even though the value is 1.
I’ve tried many things, and finally I’ve added the same value as sensors to debug the issue.
Config:

rest:
  - resource: <hidden>
    scan_interval: 1
    binary_sensor:
      - value_template: "{{ value_json['meas']['O1']['HN'] }}"
        device_class: "running"
        name: "Boiler: Aktivace regulací přebytku"
      - value_template: "{{ value_json['meas']['O1']['HE'] }}"
        device_class: "running"
        name: "Boiler: Aktivace časovačem"
    sensor:
      - value_template: "{{ value_json['meas']['O1']['HN'] }}"
        name: "Boiler: Aktivace regulací přebytku s"
      - value_template: "{{ value_json['meas']['O1']['HE'] }}"
        name: "Boiler: Aktivace časovačem s"

But no luck, even developer tools still shows all binary sensors off, even though a sensor shows the value as 1.

Docs at RESTful binary sensor - Home Assistant say:

The JSON messages can contain different values like 1, "1", TRUE, true, on, or open.

I’m out of ideas.

Ok so ignoring what the docs say for now, does this work?

rest:
  - resource: <hidden>
    scan_interval: 1 
    binary_sensor:
      - value_template: "{{ value_json['meas']['O1']['HN'] == 1 }}"
        device_class: "running"
        name: "Boiler: Aktivace regulací přebytku"
      - value_template: "{{ value_json['meas']['O1']['HE'] == 1 }}"
        device_class: "running"
        name: "Boiler: Aktivace časovačem"

The other thing to do is to slow the scan interval. You may be overloading your resource with requests. Try 10 seconds.

As you suggested, I tried it with == 1 and scan_interval: 10:

Config
rest:
  - resource: <hidden>
    scan_interval: 10
    sensor:
      - value_template: "{{ value_json['meas']['O1']['HN'] }}"
        name: "Boiler: Aktivace regulací přebytku sensor"
      - value_template: "{{ value_json['meas']['O1']['HE'] }}"
        name: "Boiler: Aktivace časovačem sensor"

      - value_template: "{{ value_json['meas']['O1']['HN'] == 1 }}"
        name: "Boiler: Aktivace regulací přebytku eq 1"
      - value_template: "{{ value_json['meas']['O1']['HE'] == 1 }}"
        name: "Boiler: Aktivace časovačem eq 1"

    binary_sensor:
      - value_template: "{{ value_json['meas']['O1']['HN'] == 1 }}"
        device_class: "running"
        name: "Boiler: Aktivace regulací přebytku"
      - value_template: "{{ value_json['meas']['O1']['HE'] == 1 }}"
        device_class: "running"
        name: "Boiler: Aktivace časovačem"

The scan_interval should be ok even at 1, since the Web UI included with the device hits the same endpoints once per second.

Trying the == 1 part doesn’t seem to work:

image

(I can’t post two images in one post as new user, so here’s a continuation:)
I tried to change it to == '1':

Config
rest:
  - resource: <hidden>
    scan_interval: 10
    sensor:
      - value_template: "{{ value_json['meas']['O1']['HN'] }}"
        name: "Boiler: Aktivace regulací přebytku sensor"
      - value_template: "{{ value_json['meas']['O1']['HE'] }}"
        name: "Boiler: Aktivace časovačem sensor"

      - value_template: "{{ value_json['meas']['O1']['HN'] == '1' }}"
        name: "Boiler: Aktivace regulací přebytku eq 1"
      - value_template: "{{ value_json['meas']['O1']['HE'] == '1' }}"
        name: "Boiler: Aktivace časovačem eq 1"

    binary_sensor:
      - value_template: "{{ value_json['meas']['O1']['HN'] == '1' }}"
        device_class: "running"
        name: "Boiler: Aktivace regulací přebytku"
      - value_template: "{{ value_json['meas']['O1']['HE'] == '1' }}"
        device_class: "running"
        name: "Boiler: Aktivace časovačem"

That seems to work for the sensor, but still not for the binary sensor:

image

That’s pretty damming evidence for an issue with the restful binary_sensor. There were some changes made to the rest platform in v2021.12. I suggest you open a new issue here:

1 Like

Issue opened here:

1 Like

what should I do when they closed the issue without any reply? https://github.com/home-assistant/core/issues/63551#event-6071061058

You let the issue go stale. You should have received a warning email about that. You get a week to reply in the issue to keep it open if it is still an issue for you.

You may have to open a new issue if no developer opens it again for you.

I don’t think Github sends out e-mails when a new tag is added.

I receive these warnings:

This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

I guess I haven’t received the email because I’m not the author of the issue? I’ll open a new one then.

Everyone subscribed to the issue (including the author) should receive it.