#Adjust words for text to speech

1 messages · Page 1 of 1 (latest)

hot talon
#

I have a sensor sensor.incidents which give this info: P 1 BNN-03 Persoon te water N363 - Winsumerweg Baflo 011411 011810 011871 013493 011531
I use it for text to speach and I would like to replace some words. Like '011810' to 'Flipper' and delete some, for me unnecessary, numbers.

I did some research and found several info and created these lines in my 'configuration.yaml':

platform: template
sensors:
incidents:
friendly_name: “Incidenten”
value_template:
state: >
{{ states('sensor.incidents') | replace("011810", "Flipper",) | }}

Although I don't get an error when I reboot HA, this doesn't work. Also not after a 'clear cache' so I do something wrong.
Can someone help me with this?

inland zephyr
hot talon
#

Thank you Micheal, I first tested this line in the template section of dev tools and I see already the replacement to 'Flipper'. I change the line in the config file. But, after a reboot, It doesn't work yet. It keeps saying '011810' instead of 'Flipper'.

#

This is the total section I have atm:

platform: template
sensors:
incidents:
friendly_name: “Incidenten”
value_template:
state: >
{{ states('sensor.incidents') | replace("011810", "Flipper",) }}

willow ridge
#

Why you always have something in the end? Now it's comma.

hot talon
#

I removed the last comma behind "Flipper" but it made no difference in speech.

willow ridge
#

Can you also use three ticks (left to the "1" on the keyboard) to wrap your code? Indentation is broken in your messages, and it can be crucial.
Also you could use template sensor in Settings - Devices and services - Helpers, this way you would see the result right away, and no need to restart HA or reload templates from dev menu (i hope you did it every time right?)

hot talon
#

You mean the tilde button? But what do you mean with "wrap you code"?
I checked the helpers but when I create an template sensor and paste my code and get a Translation error: MALFORMED_ARGUMENT. So there is something wrong.

willow ridge
#

wrap - means type three ticks (yes, those on tilda button), then paste your code, then type three ticks again.
Malformed argument means you have something wrong, yes. Try removing replace part and have just state.

hot talon
#

Sorry, I don't understand what I'm doing and how I can test this without reboot 🙂
you mean this in a 'Sensor template' in 'Settings - Devices and services - Helpers' ?

(3 tildes)
platform: template
sensors:
incidents:
friendly_name: “Incidenten”
value_template:
state: >
{{ states('sensor.incidents') | replace("011810", "Flipper",) }}
(3 tildes)

I deleted 'value_template:' and 'state: >' and now the error is gone and I can save the helper. But I guess these are necessary values 🙂

willow ridge
#

3 tildes - for this chat. Not for the template. And not tildes, but back ticks.