SOLVED: I would like to have my Magicmirror as an entity, but how?

I’m thinking it could be a switch or something.
I’ve created the rest_command part.

I’m trying to create a sensor that will reflect if the monitor is on or off.
I did this:

  - platform: rest
    name: MagicMirror-Bathroom
    resource: http://IP:8080/api/monitor/status

And the sensor then contains this result:
{"success":true,"monitor":"off"}
or
{"success":true,"monitor":"unknown"}
The latter is ‘on’

Can I get the rest sensor to show on or off by extracting the value with some sort of json template?

Try this:

binary_sensor:
  - platform: rest
    name: MagicMirror-Bathroom
    resource: http://IP:8080/api/monitor/status
    value_template: '{{ value_json.monitor == "unknown" }}'
1 Like

Ahaa, so now I get a ‘True’ in the sensor, I guess I could change it to a binary sensor instead?
I couldn’t test it in the developer tools :roll_eyes: but it looks like it works IRL.
And then I can give it a class of some sort, maybe power, there is not really one for a monitor currently :slight_smile:

1 Like

Yes, that’s how I would implement this. Even without a proper device class, you at least get a green tick icon if the monitor is on.

Well, that’s because value_json is only defined by the rest sensor.
As a workaround for testing you can add an expression like this to the template editor:

{% set value_json = {
  "monitor": "unknown"
} %}
1 Like