I currently have the exact same question with a similar code. And I can’t see why it’s not working.
Mushroom card can set up the colour permanently if it’s a button, not the script or anything else.
For that you need:
- Create “Button” helper (Devices & Services → Helpers → Create Helper
- Create automation to trigger script by the press of the button (above) - (Automations & Scenes - Automations - Create automation)
Below is the example of the automation:
alias: Diffuser - Button - OFF
description: “”
trigger:
- platform: state
entity_id:- input_button.input_button_diffuser_off
condition:
action:
- input_button.input_button_diffuser_off
- service: script.diffuser_off
metadata: {}
data: {}
mode: single