Can't get the state of a sensor in a TTS message with a function note

Hi,

Sorry I'm not a developer so probably something stupid, but can't get this to work :frowning:

If I create TTS requests with a service call node, (HA) then I get the value of the state with this option {{payload}}, so that works fine.

Now I want to use TTSUltimate with a function node, but what ever I try the, I always get the complete name of my sensor and not the value, what am I missing here?

Function node

msg.payload =

    "The temperature is " +
    "{{states.sensor.aqara_multi_sensor_buiten.state}}"

return msg

Flow

[
    {
        "id": "f474837fb704d0be",
        "type": "tab",
        "label": "DEV: Playing",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "cd3b3304bb50ce3c",
        "type": "inject",
        "z": "f474837fb704d0be",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 180,
        "wires": [
            [
                "2748f11d65adf119"
            ]
        ]
    },
    {
        "id": "bca81ecd89833131",
        "type": "debug",
        "z": "f474837fb704d0be",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 750,
        "y": 200,
        "wires": []
    },
    {
        "id": "926fe72bf8f2f051",
        "type": "ttsultimate",
        "z": "f474837fb704d0be",
        "name": "",
        "voice": "en-US-AnaNeural",
        "ssml": false,
        "sonosipaddress": "192.168.1.73",
        "sonosvolume": "30",
        "sonoshailing": "0",
        "config": "dca49eeace6ac0f9",
        "property": "payload",
        "propertyType": {},
        "rules": [],
        "playertype": "sonos",
        "speakingrate": "1",
        "speakingpitch": "0",
        "unmuteIfMuted": true,
        "x": 750,
        "y": 140,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "2748f11d65adf119",
        "type": "function",
        "z": "f474837fb704d0be",
        "name": "",
        "func": "\n\nmsg.payload =\n\n    \"The temperature is \" +\n    \"{{states.sensor.aqara_multi_sensor_buiten.state}}\"\n\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 300,
        "y": 180,
        "wires": [
            [
                "eae80ae39106a182"
            ]
        ]
    },
    {
        "id": "eae80ae39106a182",
        "type": "link out",
        "z": "f474837fb704d0be",
        "name": "",
        "mode": "link",
        "links": [
            "07b8b0130836d144"
        ],
        "x": 425,
        "y": 180,
        "wires": []
    },
    {
        "id": "07b8b0130836d144",
        "type": "link in",
        "z": "f474837fb704d0be",
        "name": "",
        "links": [
            "eae80ae39106a182"
        ],
        "x": 625,
        "y": 180,
        "wires": [
            [
                "926fe72bf8f2f051",
                "bca81ecd89833131"
            ]
        ]
    },
    {
        "id": "c0a34b3dc416a837",
        "type": "inject",
        "z": "f474837fb704d0be",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 140,
        "y": 280,
        "wires": [
            [
                "af861d2f32b955ba"
            ]
        ]
    },
    {
        "id": "fcc2e912e76771c1",
        "type": "debug",
        "z": "f474837fb704d0be",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 730,
        "y": 280,
        "wires": []
    },
    {
        "id": "af861d2f32b955ba",
        "type": "api-current-state",
        "z": "f474837fb704d0be",
        "name": "",
        "server": "36ba6f37c1b3f3c1",
        "version": 2,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "sensor.aqara_multi_sensor_buiten",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "entity"
            }
        ],
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 420,
        "y": 280,
        "wires": [
            [
                "fcc2e912e76771c1"
            ]
        ]
    },
    {
        "id": "dca49eeace6ac0f9",
        "type": "ttsultimate-config",
        "name": "Azure TTS Service",
        "noderedipaddress": "192.168.1.18",
        "noderedport": "1980",
        "purgediratrestart": "purge",
        "ttsservice": "microsoftazuretts"
    },
    {
        "id": "36ba6f37c1b3f3c1",
        "type": "server",
        "name": "Home Assistant Blue",
        "version": 1,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true
    }
]

Thanks in advance

Most here do not use HA, but looking at your flow and debug output, I would thing it would be something like this

[{"id":"f474837fb704d0be","type":"tab","label":"DEV: Playing","disabled":false,"info":""},{"id":"bca81ecd89833131","type":"debug","z":"f474837fb704d0be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":750,"y":200,"wires":[]},{"id":"926fe72bf8f2f051","type":"ttsultimate","z":"f474837fb704d0be","name":"","voice":"en-US-AnaNeural","ssml":false,"sonosipaddress":"192.168.1.73","sonosvolume":"30","sonoshailing":"0","config":"dca49eeace6ac0f9","property":"payload","propertyType":{},"rules":[],"playertype":"sonos","speakingrate":"1","speakingpitch":"0","unmuteIfMuted":true,"x":750,"y":140,"wires":[[],[]]},{"id":"07b8b0130836d144","type":"link in","z":"f474837fb704d0be","name":"","links":["eae80ae39106a182"],"x":625,"y":180,"wires":[["926fe72bf8f2f051","bca81ecd89833131"]]},{"id":"c0a34b3dc416a837","type":"inject","z":"f474837fb704d0be","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":140,"y":280,"wires":[["af861d2f32b955ba"]]},{"id":"fcc2e912e76771c1","type":"debug","z":"f474837fb704d0be","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":280,"wires":[]},{"id":"af861d2f32b955ba","type":"api-current-state","z":"f474837fb704d0be","name":"","server":"36ba6f37c1b3f3c1","version":2,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.aqara_multi_sensor_buiten","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":360,"y":280,"wires":[["fcc2e912e76771c1","d58cac46.f1bdc"]]},{"id":"eae80ae39106a182","type":"link out","z":"f474837fb704d0be","name":"","links":["07b8b0130836d144"],"x":615,"y":340,"wires":[]},{"id":"d58cac46.f1bdc","type":"function","z":"f474837fb704d0be","name":"","func":"\n\nmsg.payload =\n\n    \"The temperature is \" +\n    msg.payload\n\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":470,"y":340,"wires":[["eae80ae39106a182"]]}]

Thanks, @E1cid works great this, so much simpler than I thought, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.