SOLVED: Switch status for MagicMirror is slow in updating - any workaround?

Hi All

I’ve gotten my magic mirror sensor working, and I’ve constructed a switch that uses the sensor for status.
But the status is not update that fast, so the switch acts a bit funky.

Switch off: status shown as off
Turn on switch: status shown as on
status reverts to off
after a while the sensor is updated, and status shows on

So it’s definetely because the sensor isn’t updated as fast, but is there a way to fix it?
It doesn’t matter if there is sent multiple 'on’s or 'off’s, so it’s not a technical problem, but rather an aesthetic.

The sensor looks like this:

  - platform: rest
    name: MagicMirror_Bathroom
    resource: http://MM_IP:8080/api/monitor/status
    value_template: '{{ value_json.monitor == "unknown" }}'

The services looks like this:

rest_command:
  turn_off_mm_screen:
    url: http://MM_IP:8080/api/monitor/off
  turn_on_mm_screen:
    url: http://MM_IP:8080/api/monitor/on
  dim_mm_screen:
    url: http://MM_IP:8080/api/brightness/75
  undim_mm_screen:
    url: http://MM_IP:8080/api/brightness/100

The switch looks like this:

  - platform: template
    switches:
      magicmirror_bathroom:
        value_template: "{{ is_state('binary_sensor.magicmirror_bathroom', 'on') }}"
        turn_on:
          service: rest_command.turn_on_mm_screen
        turn_off:
          service: rest_command.turn_off_mm_screen

This works, except for the wobling of the status showing, so is there a way I can make the status update faster, or make the switch a bit slower in reverting?

I believe you’re looking for scan_interval. The default is 30 seconds.

1 Like

@123 Yup! Thankyou, that made it look much better (set it to 10s), there is still a gap, but not that crazy as before.

1 Like

This is the final switch config:

      magicmirror_bathroom:
        friendly_name: "Magicmirror Badeværelse"
        value_template: "{{ is_state('binary_sensor.magicmirror_bathroom', 'on') }}"
        turn_on:
          service: rest_command.turn_on_mm_screen
        turn_off:
          service: rest_command.turn_off_mm_screen
        entity_picture_template: >-
          {% if is_state('binary_sensor.magicmirror_bathroom', 'on') %}
            /local/mirror_on.png
          {% else %}
            /local/mirror.png
          {% endif %}

These are the images used and modified a bit.

mirror
mirror_on