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

[GHOME] Thermostat sendet bei SYNC keine TemperatureSetting Attribute #653

Open
daniel-finger opened this issue Oct 14, 2023 · 1 comment

Comments

@daniel-finger
Copy link

daniel-finger commented Oct 14, 2023

Bug
Nach dem Anlegen eines Thermostats mit den Traits

  • Thermostat_Mode
  • Thermostat_SetTemp
  • Thermostat_StatusTemp

ist dieses in Google Home nicht bedienbar.
Ich glaube es liegt daran, das die thermostatTemperatureRange bei einem SYNC nicht übermittelt wird.

Um es nachzustellen
Anlegen eines Thermostat mit den obigen drei Traits.
In das Feld Attribute vom Thermostat_SetTemp (oder in alle drei, macht keinen Unterschied) habe ich bei allen drei das folgende JSON reinkopiert:

{
    "availableThermostatModes": [
        "off",
        "heat",
        "eco"
    ],
    "thermostatTemperatureRange": {
        "minThresholdCelsius": 8,
        "maxThresholdCelsius": 29
    },
    "thermostatTemperatureUnit": "C"
}

Danach der SYNC mit "Synchronisiere meine Smart Home Geräte gestartet.
Erwartetes Verhalten
Anzeige des Thermostats und Steuerbarkeit in Google Home

Screenshots & Logfiles
Hier im Log ist zu sehen das nur
"type": "action.devices.types.THERMOSTAT",
"attributes": {},
im Beispiel Heizung Küche übergeben wird.

Logs
Request command/iobroker_danielfinger_de/ghome
Data: "{\"inputs\":[{\"intent\":\"action.devices.SYNC\"}],\"requestId\":\"6757185546605355479\"}"
[GHOME] Received action.devices.SYNC
Response: {
    "requestId": "6757185546605355479",
    "payload": {
        "agentUserId": "iobroker_danielfinger_de",
        "devices": [
            {
                "traits": [
                    "action.devices.traits.TemperatureSetting",
                    "action.devices.traits.TemperatureSetting",
                    "action.devices.traits.TemperatureSetting",
                    "action.devices.traits.TemperatureSetting"
                ],
                "customData": {
                    "set_thermostatTemperatureSetpoint": "zwave2.0.Node_008.Thermostat_Setpoint.setpoint_heating",
                    "get_thermostatTemperatureSetpoint": "zwave2.0.Node_008.Thermostat_Setpoint.setpoint_heating",
                    "get_thermostatTemperatureAmbient": "zwave2.0.Node_008.Multilevel_Sensor.airTemperature",
                    "set_thermostatMode": "zwave2.0.Node_008.Thermostat_Mode.mode",
                    "get_thermostatMode": "zwave2.0.Node_008.Thermostat_Mode.mode",
                    "get_thermostatHumidityAmbient": "zigbee.0.00158d0006795713.humidity"
                },
                "type": "action.devices.types.THERMOSTAT",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Setpoint (Heating)"
                    ],
                    "name": "Heizung Küche",
                    "nicknames": [
                        "Heizung Küche"
                    ]
                },
                "willReportState": true,
                "roomHint": "Küche",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zwave2"
                },
                "id": "zwave2.0.Node_008.Thermostat_Setpoint.setpoint_heating",
                "otherDeviceIds": [
                    {
                        "deviceId": "zwave2.0.Node_008.Thermostat_Setpoint.setpoint_heating"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.TemperatureSetting",
                    "action.devices.traits.TemperatureSetting"
                ],
                "customData": {
                    "set_thermostatMode": "zwave2.0.Node_016.Thermostat_Mode.mode",
                    "get_thermostatMode": "zwave2.0.Node_016.Thermostat_Mode.mode",
                    "get_thermostatTemperatureAmbient": "zwave2.0.Node_016.Multilevel_Sensor.airTemperature"
                },
                "type": "action.devices.types.THERMOSTAT",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Thermostat mode"
                    ],
                    "name": "Heizung Wohnzimmer",
                    "nicknames": [
                        "Heizung Wohnzimmer"
                    ]
                },
                "willReportState": true,
                "roomHint": "Wohnzimmer",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zwave2"
                },
                "id": "zwave2.0.Node_016.Thermostat_Mode.mode",
                "otherDeviceIds": [
                    {
                        "deviceId": "zwave2.0.Node_016.Thermostat_Mode.mode"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OnOff"
                ],
                "customData": {
                    "set_on": "harmony.0.Harmony_Hub.activities.Kodi",
                    "get_on": "harmony.0.Harmony_Hub.activities.Kodi"
                },
                "type": "action.devices.types.SWITCH",
                "attributes": {
                    "commandOnlyOnOff": false
                },
                "name": {
                    "defaultNames": [
                        "activity:Kodi"
                    ],
                    "name": "activity:Kodi",
                    "nicknames": [
                        "activity:Kodi"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "harmony"
                },
                "id": "harmony.0.Harmony_Hub.activities.Kodi",
                "otherDeviceIds": [
                    {
                        "deviceId": "harmony.0.Harmony_Hub.activities.Kodi"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OpenClose"
                ],
                "customData": {
                    "set_openPercent": "zigbee.0.00158d00044d9baa.opened",
                    "get_openPercent": "zigbee.0.00158d00044d9baa.opened"
                },
                "type": "action.devices.types.DOOR",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Haustür Is open"
                    ],
                    "name": "Haustür",
                    "nicknames": [
                        "Haustür"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zigbee"
                },
                "id": "zigbee.0.00158d00044d9baa.opened",
                "otherDeviceIds": [
                    {
                        "deviceId": "zigbee.0.00158d00044d9baa.opened"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OpenClose"
                ],
                "customData": {
                    "set_openPercent": "zigbee.0.00158d000429c8bf.opened",
                    "get_openPercent": "zigbee.0.00158d000429c8bf.opened"
                },
                "type": "action.devices.types.WINDOW",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Küchenfenster Is open"
                    ],
                    "name": "Küchenfenster",
                    "nicknames": [
                        "Küchenfenster"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zigbee"
                },
                "id": "zigbee.0.00158d000429c8bf.opened",
                "otherDeviceIds": [
                    {
                        "deviceId": "zigbee.0.00158d000429c8bf.opened"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OpenClose"
                ],
                "customData": {
                    "set_openPercent": "zigbee.0.00158d00041d4679.opened",
                    "get_openPercent": "zigbee.0.00158d00041d4679.opened"
                },
                "type": "action.devices.types.WINDOW",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Schlafzimmerfenster Is open"
                    ],
                    "name": "Schlafzimmerfenster",
                    "nicknames": [
                        "Schlafzimmerfenster"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zigbee"
                },
                "id": "zigbee.0.00158d00041d4679.opened",
                "otherDeviceIds": [
                    {
                        "deviceId": "zigbee.0.00158d00041d4679.opened"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OnOff"
                ],
                "customData": {
                    "set_on": "harmony.0.Harmony_Hub.activities.Fernsehen",
                    "get_on": "harmony.0.Harmony_Hub.activities.Fernsehen"
                },
                "type": "action.devices.types.SWITCH",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "activity:Fernsehen"
                    ],
                    "name": "activity:Fernsehen",
                    "nicknames": [
                        "activity:Fernsehen"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "harmony"
                },
                "id": "harmony.0.Harmony_Hub.activities.Fernsehen",
                "otherDeviceIds": [
                    {
                        "deviceId": "harmony.0.Harmony_Hub.activities.Fernsehen"
                    }
                ]
            }
        ]
    }
}
[REMOTE] Send response to 'response/iobroker_danielfinger_de/ghome: {
    "requestId": "6757185546605355479",
    "payload": {
        "agentUserId": "iobroker_danielfinger_de",
        "devices": [
            {
                "traits": [
                    "action.devices.traits.TemperatureSetting",
                    "action.devices.traits.TemperatureSetting",
                    "action.devices.traits.TemperatureSetting",
                    "action.devices.traits.TemperatureSetting"
                ],
                "customData": {
                    "set_thermostatTemperatureSetpoint": "zwave2.0.Node_008.Thermostat_Setpoint.setpoint_heating",
                    "get_thermostatTemperatureSetpoint": "zwave2.0.Node_008.Thermostat_Setpoint.setpoint_heating",
                    "get_thermostatTemperatureAmbient": "zwave2.0.Node_008.Multilevel_Sensor.airTemperature",
                    "set_thermostatMode": "zwave2.0.Node_008.Thermostat_Mode.mode",
                    "get_thermostatMode": "zwave2.0.Node_008.Thermostat_Mode.mode",
                    "get_thermostatHumidityAmbient": "zigbee.0.00158d0006795713.humidity"
                },
                "type": "action.devices.types.THERMOSTAT",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Setpoint (Heating)"
                    ],
                    "name": "Heizung Küche",
                    "nicknames": [
                        "Heizung Küche"
                    ]
                },
                "willReportState": true,
                "roomHint": "Küche",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zwave2"
                },
                "id": "zwave2.0.Node_008.Thermostat_Setpoint.setpoint_heating",
                "otherDeviceIds": [
                    {
                        "deviceId": "zwave2.0.Node_008.Thermostat_Setpoint.setpoint_heating"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.TemperatureSetting",
                    "action.devices.traits.TemperatureSetting"
                ],
                "customData": {
                    "set_thermostatMode": "zwave2.0.Node_016.Thermostat_Mode.mode",
                    "get_thermostatMode": "zwave2.0.Node_016.Thermostat_Mode.mode",
                    "get_thermostatTemperatureAmbient": "zwave2.0.Node_016.Multilevel_Sensor.airTemperature"
                },
                "type": "action.devices.types.THERMOSTAT",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Thermostat mode"
                    ],
                    "name": "Heizung Wohnzimmer",
                    "nicknames": [
                        "Heizung Wohnzimmer"
                    ]
                },
                "willReportState": true,
                "roomHint": "Wohnzimmer",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zwave2"
                },
                "id": "zwave2.0.Node_016.Thermostat_Mode.mode",
                "otherDeviceIds": [
                    {
                        "deviceId": "zwave2.0.Node_016.Thermostat_Mode.mode"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OnOff"
                ],
                "customData": {
                    "set_on": "harmony.0.Harmony_Hub.activities.Kodi",
                    "get_on": "harmony.0.Harmony_Hub.activities.Kodi"
                },
                "type": "action.devices.types.SWITCH",
                "attributes": {
                    "commandOnlyOnOff": false
                },
                "name": {
                    "defaultNames": [
                        "activity:Kodi"
                    ],
                    "name": "activity:Kodi",
                    "nicknames": [
                        "activity:Kodi"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "harmony"
                },
                "id": "harmony.0.Harmony_Hub.activities.Kodi",
                "otherDeviceIds": [
                    {
                        "deviceId": "harmony.0.Harmony_Hub.activities.Kodi"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OpenClose"
                ],
                "customData": {
                    "set_openPercent": "zigbee.0.00158d00044d9baa.opened",
                    "get_openPercent": "zigbee.0.00158d00044d9baa.opened"
                },
                "type": "action.devices.types.DOOR",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Haustür Is open"
                    ],
                    "name": "Haustür",
                    "nicknames": [
                        "Haustür"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zigbee"
                },
                "id": "zigbee.0.00158d00044d9baa.opened",
                "otherDeviceIds": [
                    {
                        "deviceId": "zigbee.0.00158d00044d9baa.opened"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OpenClose"
                ],
                "customData": {
                    "set_openPercent": "zigbee.0.00158d000429c8bf.opened",
                    "get_openPercent": "zigbee.0.00158d000429c8bf.opened"
                },
                "type": "action.devices.types.WINDOW",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Küchenfenster Is open"
                    ],
                    "name": "Küchenfenster",
                    "nicknames": [
                        "Küchenfenster"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zigbee"
                },
                "id": "zigbee.0.00158d000429c8bf.opened",
                "otherDeviceIds": [
                    {
                        "deviceId": "zigbee.0.00158d000429c8bf.opened"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OpenClose"
                ],
                "customData": {
                    "set_openPercent": "zigbee.0.00158d00041d4679.opened",
                    "get_openPercent": "zigbee.0.00158d00041d4679.opened"
                },
                "type": "action.devices.types.WINDOW",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "Schlafzimmerfenster Is open"
                    ],
                    "name": "Schlafzimmerfenster",
                    "nicknames": [
                        "Schlafzimmerfenster"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "zigbee"
                },
                "id": "zigbee.0.00158d00041d4679.opened",
                "otherDeviceIds": [
                    {
                        "deviceId": "zigbee.0.00158d00041d4679.opened"
                    }
                ]
            },
            {
                "traits": [
                    "action.devices.traits.OnOff"
                ],
                "customData": {
                    "set_on": "harmony.0.Harmony_Hub.activities.Fernsehen",
                    "get_on": "harmony.0.Harmony_Hub.activities.Fernsehen"
                },
                "type": "action.devices.types.SWITCH",
                "attributes": {},
                "name": {
                    "defaultNames": [
                        "activity:Fernsehen"
                    ],
                    "name": "activity:Fernsehen",
                    "nicknames": [
                        "activity:Fernsehen"
                    ]
                },
                "willReportState": true,
                "roomHint": "",
                "deviceInfo": {
                    "manufacturer": "ioBroker",
                    "model": "harmony"
                },
                "id": "harmony.0.Harmony_Hub.activities.Fernsehen",
                "otherDeviceIds": [
                    {
                        "deviceId": "harmony.0.Harmony_Hub.activities.Fernsehen"
                    }
                ]
            }
        ]
    }
}
[GHOME] Status reported: {"requestId":"1697263323617.87568"}

Versions:

  • Adapter version: 2.0.11 -> der zur Zeit aktuelle commit 7f4fb87
  • JS-Controller version: 5.0.12
  • Node version: v18.17.1
  • Operating system: Raspbian GNU/Linux 11 (bullseye)
@daniel-finger
Copy link
Author

daniel-finger commented Oct 14, 2023

Ich konnte es eingrenzen auf den Codeblock:

                if (!smartName.ghAttributes && traitEnum[smartName.ghTraits[0]].defaultAttributes) {
                    const defaultAttributes = traitEnum[smartName.ghTraits[0]].defaultAttributes;
                    result[id].attributes = JSON.parse(defaultAttributes);
                    const obj = await this.adapter.getForeignObjectAsync(id);
                    if (!obj.common ||
                        !obj.common.smartName ||
                        !obj.common.smartName.ghAttributes ||
                        obj.common.smartName.ghAttributes !== defaultAttributes
                    ) {
                        this.adapter.log.error('awaiting extend');
                        await this.adapter.extendForeignObjectAsync(id, {
                            common: {
                                smartName: {
                                    ghAttributes: defaultAttributes,
                                },
                            },
                        });
                    }
                } else {
                    result[id].attributes = {};
                }
            }

in der Funktion processState. Der geht hier in den else Zweig rein.
Ich hab den Code mal angepasst:

if (!smartName.ghAttributes && traitEnum[smartName.ghTraits[0]].defaultAttributes) {
                    const defaultAttributes = traitEnum[smartName.ghTraits[0]].defaultAttributes;
                    result[id].attributes = JSON.parse(defaultAttributes);
                    const obj = await this.adapter.getForeignObjectAsync(id);
                    if (!obj.common ||
                        !obj.common.smartName ||
                        !obj.common.smartName.ghAttributes ||
                        obj.common.smartName.ghAttributes !== defaultAttributes
                    ) { 
                        this.adapter.log.error('awaiting extend');
                        await this.adapter.extendForeignObjectAsync(id, {
                            common: {
                                smartName: {
                                    ghAttributes: defaultAttributes,
                                },
                            },
                        });
                    }
                } else {
                    this.adapter.log.error('!smartName.ghAttributes && traitEnum[smartName.ghTraits[0]].defaultAttributes was true');
                    if (!smartName.ghAttributes) {
                            this.adapter.log.error('!smartName.ghAttributes evaluated to true: ' + smartName.ghAttributes);
                            result[id].attributes = {};
                    } else {
                        this.adapter.log.error('!smartName.ghAttributes evaluated to false: ' + smartName.ghAttributes);
                    }
                    if (traitEnum[smartName.ghTraits[0]].defaultAttributes) {
                         this.adapter.log.error('traitEnum[smartName.ghTraits[0]].defaultAttributes evaluated to true');
                    }
                }
            }

Das Log sagt dazu:

!smartName.ghAttributes && traitEnum[smartName.ghTraits[0]].defaultAttributes was true
!smartName.ghAttributes evaluated to false: {"availableThermostatModes":["off","heat","eco"],"thermostatTemperatureRange":{"minThresholdCelsius":8,"maxThresholdCelsius":29},"thermostatTemperatureUnit":"C"}
traitEnum[smartName.ghTraits[0]].defaultAttributes evaluated to true

Die zusätzliche Prüfung auf if (!smartName.ghAttributes) { im else Zweig fixed am Ende das Problem.

Ich vermute hier soll attributes auf jeden Fall erzeugt werden mit den Trait default Attributen oder eben {} wenn es danach immer noch nicht gefüllt ist?
Ich muss zugeben, ich verstehe nicht genau, was hier passieren soll. Sollte es nicht reichen, wenn am Ende nur noch gecheckt wird ob result[id].attributes undefined ist? So ganz generell?

daniel-finger added a commit to daniel-finger/ioBroker.iot that referenced this issue May 20, 2024
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

No branches or pull requests

1 participant