This line generate wrong messages.
I had to change the last line with only:
{{ actions[trigger.to_state.state] }}
but error Error while executing automation automation.rileva_vibration. Invalid data for call_service at pos 1: required key not provided @ data[‘message’] is still there
Thank you very much for your help.
then if trigger.to_state.state is NOT found in the actions dictionary, you will get an error message.
Change it to this which simply reports whatever value is received. This should not generate any error messages. If it does, then there’s something else causing it.
With your last line always generates a third empty event ( ) ’
It is also true that the error Error while executing automation automation.rileva_vibration. Invalid data for call_service at pos 1: required key not provided @ data[‘message’] is no longer generated
Your automation calls the Telegram service and sets message to trigger.to_state.state. However, if sensor.vibro contains no state (it is blank) then message is assigned a blank value which is invalid and you get the error: required key not provided @ data[‘message’].
At this point, I need to get a message whenever one of the three events goes wild.
So, how can I prevent the empty (blank) message will be generated and not having the error required key not provided @ data[‘message’]?
You’re welcome! Glad to hear it works well for you.
Please mark my (previous) post as the Solution. Only you, the author of this topic, can do that. After you select the Solution tag, my post will become easier to find for other users (who may be seeking a similar solution for the Xiaomi vibration sensor). A checkmark will also appear next to the topic’s title, indicating it has been solved.