Wallpanel screen status and set brightness

I am trying to do 2 things using MQTT.

I am using mqtt light to set the brightness and turn on the screen.
So far I have managed to turn on the screen.
I cant set the brightness…
lights.yaml:

- platform: mqtt
  name: 'Galaxy Screen'
  state_topic: 'home/devices/master/galaxy/state'
  state_value_template: '{% if value_json.screenOn == true %}{"wake": true}{% else %}OFF{% endif %}'
  command_topic: 'home/devices/master/galaxy/command'
  payload_on: '{"wake": true}'
  payload_off: 'OFF'
  brightness_command_topic: "home/devices/master/galaxy/command {'brightness':}"
  brightness_state_topic: 'home/devices/master/galaxy/state'
  brightness_value_template: '{{value_json.brightness}}'

The reason my brightness_command_topic is like that, is because I am testing things and almost made it… kinda…
I need help with that.
When I publish from developer tools the message I get this response from mosquitto:

home/devices/master/galaxy/command {‘brightness’: 100}

And the brightness sets perfectly.
When I am trying using the light card, with the current setup I get this:

home/devices/master/galaxy/command {‘brightness’:} 130

How do I include the value inside the brackets?
What is the correct way to do this?

Ok, I made some progress here. I have managed to set the brightness and turn on the screen. But I am having trouble on getting the status of the screen combined with brightness. I can only get the status. I tried this:

- platform: mqtt
  schema: template
  name: 'Galaxy Screen'
  state_topic: 'home/devices/master/galaxy/state'
  # state_template: '{% if value_json.screenOn == true %}on{% else %}off{% endif %}' // This worked for the screen status only, but I get no brightness status.
  state_template: >
    {
    {% if value_json.screenOn == true %}on{% else %}off{% endif %}
    {%- if brightness is defined -%}
    ,'brightness': {{ brightness }}
    {%- endif -%}
    }
  command_topic: 'home/devices/master/galaxy/command'
  command_on_template: >
    {"wake": true
    {%- if brightness is defined -%}
    ,'brightness': {{ brightness }}
    {%- endif -%}}
  command_off_template: >
    {"wake": false
    {%- if brightness is defined -%}
    ,'brightness': {{ brightness }}
    {%- endif -%}}
  brightness_command_topic: 'home/devices/master/galaxy/command'
  brightness_state_topic: 'home/devices/master/galaxy/state'
  brightness_value_template: '{{value_json.brightness}}'

Can someone help me?

Also ignore the command_off_template as there is no option to turn off the screen according to wallpanel docs.

EDIT: Here is the wallpanel state when the screen is on or off:

home/devices/master/galaxy/state {“currentUrl”:“https://192.168.1.3:8123/”,“screenOn”:true,“brightness”:25}

home/devices/master/galaxy/state {“currentUrl”:“https://192.168.1.3:8123/”,“screenOn”:false,“brightness”:25}

This is what I’m using:

light:
  - platform: mqtt
    schema: template
    name: 'WallPanel Screen'
    state_topic: 'wallpanel/mywallpanel/state'
    state_template: '{% if value_json.screenOn == true %}on{% else %}off{% endif %}'
    brightness_template: '{{ value_json.brightness }}'
    command_topic: 'wallpanel/mywallpanel/command'
    command_on_template: >
      { "wake": true
      {%- if brightness is defined -%}
      ,"brightness": {{ brightness }}
      {%- endif -%}}
    command_off_template: '{ "wake": false }'
    json_attributes_topic: 'wallpanel/mywallpanel/state'
1 Like

I have used the following sensor, to be able to turn on the screen of the tablet and it works really well, but I have a problem the button is not lit, that is, the pulse turns on but immediately turns off even when the screen is on, there is a way to adjust this problem

Thank´s