Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select node set value doesn't work #1145

Closed
Wielebny666 opened this issue Nov 9, 2023 · 4 comments · Fixed by #1146
Closed

Select node set value doesn't work #1145

Wielebny666 opened this issue Nov 9, 2023 · 4 comments · Fixed by #1146

Comments

@Wielebny666
Copy link

Wielebny666 commented Nov 9, 2023

Describe the bug

Cannot set select node by sending a value in payload.

To Reproduce

No response

Expected behavior

No response

Screenshots

image

Example Flow

[
    {
        "id": "8bc181182e484793",
        "type": "inject",
        "z": "25a95a347589e3d2",
        "name": "",
        "props": [],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "x": 350,
        "y": 2300,
        "wires": [
            [
                "3e447e0c6e4269f9"
            ]
        ]
    },
    {
        "id": "3e447e0c6e4269f9",
        "type": "api-current-state",
        "z": "25a95a347589e3d2",
        "name": "random option",
        "server": "2f3b3f1b027122cb",
        "version": 3,
        "outputs": 1,
        "halt_if": "",
        "halt_if_type": "str",
        "halt_if_compare": "is",
        "entity_id": "select.thermostats_preset_config",
        "state_type": "str",
        "blockInputOverrides": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "( \t  $c := $entity().state;\t  $a := function($acc, $val){$c = $val ? $acc : $append($acc, $val)};\t  $r := $shuffle($entity().attributes.options);\t$reduce($r, $a, [])[0]\t)",
                "valueType": "jsonata"
            }
        ],
        "for": "0",
        "forType": "num",
        "forUnits": "minutes",
        "override_topic": false,
        "state_location": "payload",
        "override_payload": "msg",
        "entity_location": "data",
        "override_data": "msg",
        "x": 556,
        "y": 2300,
        "wires": [
            [
                "fba9f03026226eca",
                "f7a416ef39881784"
            ]
        ]
    },
    {
        "id": "fba9f03026226eca",
        "type": "debug",
        "z": "25a95a347589e3d2",
        "name": "debug 119",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 780,
        "y": 2300,
        "wires": []
    },
    {
        "id": "f7a416ef39881784",
        "type": "ha-select",
        "z": "25a95a347589e3d2",
        "name": "Home thermostats preset",
        "version": 1,
        "debugenabled": false,
        "inputs": 1,
        "outputs": 1,
        "entityConfig": "e5dc675d987ab384",
        "mode": "set",
        "value": "payload",
        "valueType": "msg",
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "value"
            },
            {
                "property": "previousValue",
                "propertyType": "msg",
                "value": "",
                "valueType": "previousValue"
            }
        ],
        "x": 830,
        "y": 2360,
        "wires": [
            [
                "89695b2c4adebd8b"
            ]
        ]
    },
    {
        "id": "89695b2c4adebd8b",
        "type": "debug",
        "z": "25a95a347589e3d2",
        "name": "debug 122",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 1000,
        "y": 2300,
        "wires": []
    },
    {
        "id": "2f3b3f1b027122cb",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    },
    {
        "id": "e5dc675d987ab384",
        "type": "ha-entity-config",
        "server": "2f3b3f1b027122cb",
        "deviceConfig": "",
        "name": "Home thermostats preset config",
        "version": "6",
        "entityType": "select",
        "haConfig": [
            {
                "property": "name",
                "value": "Thermostats preset config"
            },
            {
                "property": "icon",
                "value": ""
            },
            {
                "property": "entity_category",
                "value": ""
            },
            {
                "property": "entity_picture",
                "value": ""
            },
            {
                "property": "options",
                "value": [
                    "boost",
                    "eco",
                    "comfort"
                ]
            }
        ],
        "resend": false,
        "debugEnabled": true
    }
]

Environment Information

Version: 3.1.0

Home Assistant version: 2023.10.5
Companion version: 3.1.1

Node-RED version: 3.1.0
Docker: yes
Add-on: no

Node.js version: v16.20.2 x64 linux
OS: Linux 6.2.16-19-pve x64

node-red-contrib-home-assistant-websocket ver: 0.58.1

Additional context

No response

@zachowj
Copy link
Owner

zachowj commented Nov 9, 2023

Your example works correctly when I test it.

What version of this package and the companion component are installed?

If you're running the latest version of this package you can use this flow to get the required information.

@Wielebny666
Copy link
Author

For me, as you can see in the logs, it works fine 2-3 times. After a while it doesn't work and TypeError

image

@zachowj
Copy link
Owner

zachowj commented Nov 10, 2023

I was unable to reproduce the error but changed the validation that could have been throwing the error. Reopen this if it doesn't fix it.

@Wielebny666
Copy link
Author

Wielebny666 commented Nov 10, 2023

Still doesn't work, only the error message has changed :-(

after restart node-red:
image

Now I think I know what breaks this component.
Added "update config node" and dynamic icon change.
The options list is probably being destroyed.

[ { "id": "b9aaec72ed56f167", "type": "ha-update-config", "z": "25a95a347589e3d2", "name": "Home thermostats preset icon change", "server": "2f3b3f1b027122cb", "entityConfig": "41350adce900ef07", "version": 0, "outputProperties": [], "x": 1170, "y": 2080, "wires": [ [] ] }, { "id": "3cfb467a628c0e68", "type": "change", "z": "25a95a347589e3d2", "name": "", "rules": [ { "t": "delete", "p": "payload", "pt": "msg" }, { "t": "set", "p": "payload.icon", "pt": "msg", "to": "mdi:sofa", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 840, "y": 2080, "wires": [ [ "b9aaec72ed56f167" ] ] }, { "id": "9cae439f988e6667", "type": "switch", "z": "25a95a347589e3d2", "name": "", "property": "payload", "propertyType": "msg", "rules": [ { "t": "eq", "v": "eco", "vt": "str" }, { "t": "eq", "v": "comfort", "vt": "str" }, { "t": "eq", "v": "boost", "vt": "str" } ], "checkall": "true", "repair": false, "outputs": 3, "x": 630, "y": 2080, "wires": [ [ "14dd0c7a9645128f" ], [ "3cfb467a628c0e68" ], [ "275d87fdb9503e66" ] ] }, { "id": "275d87fdb9503e66", "type": "change", "z": "25a95a347589e3d2", "name": "", "rules": [ { "t": "delete", "p": "payload", "pt": "msg" }, { "t": "set", "p": "payload.icon", "pt": "msg", "to": "mdi:rocket-launch", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 840, "y": 2140, "wires": [ [ "b9aaec72ed56f167" ] ] }, { "id": "14dd0c7a9645128f", "type": "change", "z": "25a95a347589e3d2", "name": "", "rules": [ { "t": "delete", "p": "payload", "pt": "msg" }, { "t": "set", "p": "payload.icon", "pt": "msg", "to": "mdi:leaf", "tot": "str" } ], "action": "", "property": "", "from": "", "to": "", "reg": false, "x": 840, "y": 2020, "wires": [ [ "b9aaec72ed56f167" ] ] }, { "id": "e48ca937a016821f", "type": "ha-select", "z": "25a95a347589e3d2", "name": "Home thermostats preset", "version": 1, "debugenabled": false, "inputs": 0, "outputs": 1, "entityConfig": "41350adce900ef07", "mode": "listen", "value": "payload", "valueType": "msg", "outputProperties": [ { "property": "payload", "propertyType": "msg", "value": "", "valueType": "value" }, { "property": "previousValue", "propertyType": "msg", "value": "", "valueType": "previousValue" } ], "x": 310, "y": 2080, "wires": [ [ "9cae439f988e6667" ] ] }, { "id": "8bc181182e484793", "type": "inject", "z": "25a95a347589e3d2", "name": "", "props": [], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "x": 350, "y": 2300, "wires": [ [ "3e447e0c6e4269f9" ] ] }, { "id": "3e447e0c6e4269f9", "type": "api-current-state", "z": "25a95a347589e3d2", "name": "random option", "server": "2f3b3f1b027122cb", "version": 3, "outputs": 1, "halt_if": "", "halt_if_type": "str", "halt_if_compare": "is", "entity_id": "select.thermostats_preset_config", "state_type": "str", "blockInputOverrides": false, "outputProperties": [ { "property": "payload", "propertyType": "msg", "value": "( \t $c := $entity().state;\t $a := function($acc, $val){$c = $val ? $acc : $append($acc, $val)};\t $r := $shuffle($entity().attributes.options);\t$reduce($r, $a, [])[0]\t)", "valueType": "jsonata" } ], "for": "0", "forType": "num", "forUnits": "minutes", "override_topic": false, "state_location": "payload", "override_payload": "msg", "entity_location": "data", "override_data": "msg", "x": 556, "y": 2300, "wires": [ [ "fba9f03026226eca", "f7a416ef39881784" ] ] }, { "id": "fba9f03026226eca", "type": "debug", "z": "25a95a347589e3d2", "name": "debug 119", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 780, "y": 2300, "wires": [] }, { "id": "f7a416ef39881784", "type": "ha-select", "z": "25a95a347589e3d2", "name": "Home thermostats preset", "version": 1, "debugenabled": false, "inputs": 1, "outputs": 1, "entityConfig": "41350adce900ef07", "mode": "set", "value": "payload", "valueType": "msg", "outputProperties": [ { "property": "payload", "propertyType": "msg", "value": "", "valueType": "value" }, { "property": "previousValue", "propertyType": "msg", "value": "", "valueType": "previousValue" } ], "x": 830, "y": 2360, "wires": [ [ "89695b2c4adebd8b" ] ] }, { "id": "89695b2c4adebd8b", "type": "debug", "z": "25a95a347589e3d2", "name": "debug 122", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "statusVal": "", "statusType": "auto", "x": 1070, "y": 2360, "wires": [] }, { "id": "2f3b3f1b027122cb", "type": "server", "name": "Home Assistant", "version": 5, "addon": false, "rejectUnauthorizedCerts": false, "ha_boolean": "y|yes|true|on|home|open", "connectionDelay": true, "cacheJson": true, "heartbeat": true, "heartbeatInterval": "10", "areaSelector": "friendlyName", "deviceSelector": "friendlyName", "entitySelector": "friendlyName", "statusSeparator": ": ", "statusYear": "hidden", "statusMonth": "short", "statusDay": "numeric", "statusHourCycle": "default", "statusTimeFormat": "h:m", "enableGlobalContextStore": false }, { "id": "41350adce900ef07", "type": "ha-entity-config", "server": "2f3b3f1b027122cb", "deviceConfig": "", "name": "Thermostats preset config", "version": "6", "entityType": "select", "haConfig": [ { "property": "name", "value": "Thermostats preset config" }, { "property": "icon", "value": "" }, { "property": "entity_picture", "value": "" }, { "property": "entity_category", "value": "" }, { "property": "options", "value": [ "comfort", "eco", "boost" ] } ], "resend": false, "debugEnabled": true } ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants