Deleted my question as I suspect I just need to spend a whole week working out what ‘template’ means in this context.
The last ‘template’ I used was a piece of cardboard with a circle on it to cut out the right sized hole in my ceiling for a fan…
so in your post you use a template as a cardboard circle to cut out a hole. A ‘predefined geometric shape that matches with fan for proper installation’
In the HA world a template is just a string/data predefined format that is read by the system that allows for proper function.
All you do by using template is say, I have this specific data that I want to use this specific way and spit out to look like this specific group of words/numbers/text.
It’s a bit confusing to grasp at the beginning but once you make a few automations,etc with templates you’ll have an AHA! moment and it will all make sense.
I’m sure it will. Mostly it’s the stuff inside the curly brackets that is causing me most trouble right now it think.
So far my journey into HA has me typing strings in YAML, JSON and now I read that templates are in Jinja2 syntax ?
Sheesh.
I’m trying to get success by code testing via the HA hass.io Service Tool but I suspect that the coding examples I see in YAML syntax won’t work in that directly. It needs to be converted to JSON syntax I think and I’ve had a crack at that. That is making it harder I sure.
This fails so far. It just sends me the message and the function back to my phone verbatim rather than the state of a Sonoff switch.
{
"title":"Test title",
"message": "Switch1 is { { states.switch.sonoff_switch1.state } } ",
"target": [
"device/Samsung SM-J105Y"
]
}
Not sure if this is the exact issue but curly braces should be double and next to each other {{ states.light.light_name.state }}
etc.
also for the state of the light try "Switch1 is {{ states('switch.sonoff_switch1') }}"
mta:added something
Removing spaces didn’t help but changing to {{ states(‘switch.sonoff_switch1’) }} now works
The examples shown in the Pushbullet example looks like this with no inner brackets…
message: "Fan running because current is {{ states.sensor.furnace.state }} amps"
PS. Thanks for your help, it probably saved me another evening or three of head scratching.
Have a great Xmas.
Martin
Glad you got it working