Trying to set up a light with RESTful api for MagicMirror?

I have a magicmirror.
After the defunct integration, I’ve reset it to use MQTT to turn the monitor on and off.
I can’t adjust the brigthness this way, so I wanted to look into using the RESTful(ish) remote_control module for the magic mirror so I can adjust the brightness as well.
I’m not a coder, so I can’t figure out how to fix the integration (GitHub - sindrebroch/ha-magicmirror: Custom HomeAssistant-integration for MagicMirror) I can see all the ‘api’ commands looks correct, so it must be something in the python that is no longer aligned with HA…

I’ve gotten three files created.
A rest_command
A sensor
A light

The list of API commands are shown here:
https://ezeholz.com.ar/MMM-Remote-Control/#/API/get_api_brightness___setting_

In my rest_command I have three commands defined:

turn_on_monitor:
  url: "http://10.11.12.7:8080/api/monitor/on?apiKey=xxx"
  method: get

turn_off_monitor:
  url: "http://10.11.12.7:8080/api/monitor/off?apiKey=xxx"
  method: get

set_monitor_brightness:
  url: "http://10.11.12.7:8080/api/brightness/{{ brightness }}?apiKey=apiKey=xxx"
  method: get

Then I have a sensor to tell if the light is turned on or off:

- platform: rest
  name: MagicMirror Monitor rest
  resource: "http://10.11.12.7:8080/api/monitor/?apiKey=xxx"
  method: GET
  value_template: "{{ value_json.monitor }}"

Finally I have the light defined:

    magicmirror_monitor_rest:
      friendly_name: "MagicMirror Monitor rest"
      turn_on:
        service: rest_command.turn_on_monitor
      turn_off:
        service: rest_command.turn_off_monitor
      value_template: "{{ is_state('sensor.magicmirror_monitor_rest', 'on') }}"
      set_level:
        service: rest_command.set_monitor_brightness
        data_template:
          brightness: "{{ (brightness / 255 * 100) | int }}"

This works for turning it on and off (reporting the state has a delay of upto 15s), but ir does not work for setting brightness.
If I use postman and send a URL like
http://10.11.12.7:8080/api/brightness/50?apiKey=xxx
It sets the brightness to 50% (I can get it reported by simply not giving the 50 as a value).
But I don’t see anything change when I try to use the light from HA?

You can fix that delay:

    magicmirror_monitor_rest:
      friendly_name: "MagicMirror Monitor rest"
      turn_on:
        - action: rest_command.turn_on_monitor
        - delay: 1
        - action: homeassistant.update_entity
          data:
            entity_id:  sensor.magicmirror_monitor_rest
      turn_off:
        - action: rest_command.turn_off_monitor
        - delay: 1
        - action: homeassistant.update_entity
          data:
            entity_id:  sensor.magicmirror_monitor_rest
      value_template: "{{ is_state('sensor.magicmirror_monitor_rest', 'on') }}"
      set_level:
        service: rest_command.set_monitor_brightness
        data:
          brightness: "{{ (brightness / 255 * 100) | int }}"

Not sure why the brightness is not working.

Hi @tom_l , brilliant, thankyou, that fixed the delay perfectly.
Now I just need to figure out how to ‘read’ what the API call is doing for brightness.

Darned, and I just now realized why the ‘brightness’ wasn’t working.
I had written

apiKey=apiKey=

in the request, after removing the superflous, it worked like a charm!