Automating an entity value change (thermostat brightness percentage)

I have a Meross thermostart with adjustable standby brightness. The entity name is
number.smart_thermostat_24061746095039601201c4e7ae04efb8_screen_brightness_standby

It’s normal value is at 12%. I can change this value manually by viewing it’s history and changing the percentage.

I’d like to make an automation that sets the brightness at night (22:00 to 7:00) to 0%, then revert back to 12% in the morning but I don’t know how. If only it were a light bulb, I could figure it out! I tried to find something in automations, but I can’t find an appropriate ‘Action’ to change the value - maybe I should be using a script? A Helper?

alias: example
triggers:
  - id: '0'
    trigger: time
    at: '22:00:00'
  - id: '12'
    trigger: time
    at: '07:00:00'
conditions: []
actions:
  - action: number.set_value
    target:
      entity_id: number.smart_thermostat_24061746095039601201c4e7ae04efb8_screen_brightness_standby
    data:
      value: "{{ trigger.id | int(0) }}"

Reference

Number - Actions

1 Like

Any progress to report?

1 Like

I tried using that in automation.yaml, but I was getting trigger.id errors (Error rendering data template: UndefinedError: ‘trigger’ is undefined) that I didn’t understand. I was reading about automations to figure out why, but I ended up making two separate automations with the number.set_value action. So I guess it’s solved. Thanks for the help!

- id: '1743666168125'
  alias: thermo brightness off
  description: ''
  triggers:
  - trigger: time
    at: 22:00:00
  conditions: []
  actions:
  - action: number.set_value
    metadata: {}
    data:
      value: '0'
    target:
      entity_id: number.smart_thermostat_24061746095039601201c4e7ae04efb8_screen_brightness_standby
  mode: single
- id: '1743666071148'
  alias: raise thermo brightness
  description: ''
  triggers:
  - trigger: time
    at: '7:00:00'
  conditions: []
  actions:
  - action: number.set_value
    metadata: {}
    data:
      value: '12'
    target:
      entity_id: number.smart_thermostat_24061746095039601201c4e7ae04efb8_screen_brightness_standby
  mode: single

missing quotes here

at: 22:00:00

You have them here

 triggers:
  - trigger: time
    at: '7:00:00'

Should be

triggers:
  - trigger: time
    at: "07:00:00"
1 Like

When did you get that error?

  • If you got the error when the automation triggered at 07:00 or 22:00 then you made some sort of mistake when you defined the Time Triggers.

  • If you got the error when you tried to test the automation by executing its Run command then that’s a mistake. The Run command only executes the actions but the trigger variable only exists if the automation’s trigger is triggered. This is explained in the Troubleshooting Automations section:

Note that any trigger ID used in your triggers will not be active when you test this way. The Trigger ID or any data passed by in the trigger data in conditions or actions can’t be tested directly this way.


Be advised that the example I provided does work. I use the same technique in my own automations and have suggested it to many other users for several years.


Naturally two separate automations will work and can be tested with the Run command because they don’t reference any non-existent variables (like trigger).

Seeing that your original question was to find the correct action (number.set_value), and I supplied it in my example, please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which indicates to others that the topic has been solved. This helps other users find answers to similar questions.

2 Likes

I didn’t notice the missing quotes! It seems to work without the quotes, but I added them as per your suggestion.

I’m sure it was because I added it to automations.yaml incorrectly. I’d never used that method to add automations before. I do prefer your more elegant solution so I’ll try it again now that I’m more familiar with the correct syntax.