I like to create and automation if the brightness of the light changes by x percent. Today I have the current brightness in a percent with a template. BUT I cant for the the life of me figure out how to compare current vs previous brightness and find percent changed in either increase or decreace brightness. Thank you in advance for your help.
Assuming you have an automation that uses a State Trigger to monitor the light’s brightness, the information you want is contained in the automation’s trigger
variable.
Subtract trigger.to_state.attributes.brightness
from trigger.from_state.attributes.brightness
to get the difference.