I think you need to encode it if you have commas in teh templates. There should be an example of URL encoding in the docs
I have read the docs and attempted to use the formatting and I must not being doing something right as I get a toast message that the format is incorrect still. I’ve tried putting the formatting in several different areas. I have two that don’t work. The below one and one that is a list of random sentences…
service: notify.mobile_app_gddog13
data:
message: command_broadcast_intent
title: Text
data:
channel: net.dinglisch.android.taskerm
group: >-
"EXTRA:text:This weather 🌧 report is sponsored by the weather station and
provided to you by your hubby. 👅 The Current Temp is {{ states
('sensor.weather_pws' ) | int }}. 🌡️ Today's Forecast says {{ state_attr
('weather.kfnt_daynight', 'forecast' ).0.detailed_description }}.
Tomorrow's Forecast says {{ state_attr ('weather.kfnt_daynight',
'forecast' ).2.detailed_description }}:char"
Any ideas where I went wrong?
try:
group: "extra_text:This weather 🌧 report is sponsored by the weather station and
provided to you by your hubby. 👅 The Current Temp is {{ states
('sensor.weather_pws' ) | int }}. 🌡️ Today's Forecast says {{ state_attr
('weather.kfnt_daynight', 'forecast' ).0.detailed_description }}.
Tomorrow's Forecast says {{ state_attr ('weather.kfnt_daynight',
'forecast' ).2.detailed_description }}"
Can you also share what the rendered template looks like please? Because if any commas are in the rendered template then you will need to URL encode them in a separate sensor/input_text so they can be properly displayed in the app.
I’m not sure what you mean the template is above in the code.
The info for part of the templates comes from the NWS and I have no control over where they put commas in their forecasts so I may have to leave it this way.
The code you posted above puts me in the right direction for the random list one, which I’ll try when I’m back home.
what i meant was that if there are commas in the description then the only way you could send it as an intent extra is to follow the URL encoding for the text. You would basically need to have a sensor that converts the text into URL encoding and use that in its place to avoid the commas messing up the extras. In other words you need to have that sensor replace commas with %2c
as that is the correct url encoding for a comma. See what I mean? You actually have to provide the text output in the expected format.
Is this a possibility when the it’s forecast like that from a 3rd party? How difficult is it if so?
Like this is the current forecast. It could change in 2 hours… it’ll switch for sure at 6pm… and then again at 6am.
“Mostly sunny. High near 79, with temperatures falling to around 77 in the afternoon. West wind around 13 mph, with gusts as high as 20 mph.”
you’ll need to spruce up your jinja skills but you can probably use the replace
function to do so.
https://jinja.palletsprojects.com/en/latest/templates/#jinja-filters.replace
so probably something like, I am no jjinja expert so you may need to look for help elsewhere if you cant figure this out
{{ state_attr ('weather.kfnt_daynight', 'forecast' ).2.detailed_description|replace(",", "%2c" }}
And this would go into another input text?
or a template sensor, up to you on how you want to store the text
That was the correct code to replace it. Now to make a template sensor when i get home and see how that works out.
With the format "extra_text:…Tasker is only sending the variable name %text. in a text.
I didn’t end up needing it for the weather one. I just did as you suggested and put them in a text input. Instead of doing %2ca for the commas I just replaced them with an empty string. Seems the intents accept templates just not commas.
{{ state_attr('weather.kfnt_daynight', 'forecast' ).0.detailed_description | replace (",", "") }}
Now to work on the random sentence strings.
commas are reserved for splitting up extra values so you can have more than 1 extra variable.
per the docs:
Extras are also supported under the group parameter. As there can be any number of extras added to the intent we will need to split each extra by a comma ,. Then each extra name and value needs to be separated by a colon :. The below example shows you how to turn on an alarm labeled work in the Sleep as Android application. In this example there are 2 extras being added to the intent.
I figured that was the issue. The random list works just fine with making sure all out of place commas are removed. It was a long list of some pretty long sentences that was an interesting task even using the search key lol.
One other thing I noticed…if you edit in yaml and it turn say a list into a block the intent gets angry about that. It appears you have to ensure you save it as one straight line.
Yes the app expects to get everything in one string so we can parse it properly. Thats why we have multiple detailed examples in the docs.
I tend to go back and forth between UI and Yaml a lot lmao. That forces changes I don’t want it too lol.