FilipDem / Domoticz-NEST-plugin

NEST Plugin for Domoticz using the Google credentials.
13 stars 4 forks source link

Nest Protect devices not updated #8

Closed qhajkasem closed 4 years ago

qhajkasem commented 4 years ago

Hi,

I have three Nest protect devices and I installed the latest version of this plugin. It appears to be working (devices are created) but the devices are not updated with the latest status. The LastSeen timestamp is the time of the startup of Domoticz.

Looks like this function does not include the Protect devices.

def NestPushUpdate(self, device=None, field=None, value=None, device_name=None):
    self.nest_update_status = _NEST_UPDATE_STATUS_UPDATE_SWITCH
    Domoticz.Debug("Start thread Push")
    if field == _NEST_HEATING_TEMP:
        if self.myNest.SetTemperature(device, value):
            UpdateDeviceByName(device_name, value, value)
    elif field == _NEST_AWAY:
        if self.myNest.SetAway(device, value):
            if value == True:
                UpdateDeviceByName(device_name, 1, 1)
            else:
                UpdateDeviceByName(device_name, 0, 0)
    elif field == _NEST_ECO_MODE:
        if self.myNest.SetEco(device, value):
            if value == 'manual-eco':
                UpdateDeviceByName(device_name, 1, 1)
            else:
                UpdateDeviceByName(device_name, 0, 0)
    elif field == _NEST_HEATING:
        if self.myNest.SetThermostat(device, value):
            image = Images[_IMAGE_NEST_HEATING_OFF].ID
            if value == 'heat':
                UpdateDeviceByName(device_name, 1, 1, image)
            else:
                UpdateDeviceByName(device_name, 0, 0, image)
FilipDem commented 4 years ago

Hi, You have to look in the "onHeartBeat". There you will see that they are updated. See code below. The function "NestPushUpdate" is only to change the devices from Domoticz (but there are no such functions for the Nest Protect).

I have the habit to not "update the device" and this means that the "last seen" is not update as long as the status is not changed. And seen (I would expect) that you don't have immediately alarms, the status won't change often... And it will also depend your "update interval". If you set this on 15 min, than it is possible that an alarm of 30 seconds is not detected... On the other hand, I would not set the update interval lower than 2 minutes.

            for device in self.myNest.protect_list:
                info = self.myNest.GetProtectInformation(device)
                Domoticz.Debug(json.dumps(info))
                #Create device if required and allowed
                device_name = info['Where'] + ' ' + _NEST_PROTECT
                if not fnmatch.filter([Devices[x].Name for x in Devices], '*'+device_name):
                    Domoticz.Device(Unit=len(Devices)+1, Name=device_name, Type=244, Subtype=73, Switchtype=5, Image=Images[_IMAGE_NEST_PROTECT].ID, Used=1).Create()
                if info['Smoke_status']:
                    UpdateDeviceByName(device_name, 1, 1)
                else:
                    UpdateDeviceByName(device_name, 0, 0)
qhajkasem commented 4 years ago

Thanks for the feedback and good point. My update-interval is 5 minutes and I didn't realize that the plugin could miss status changes (had a smoke alarm this morning and the devices were not updated). I will lower the interval and you can close this issue.

Regards and thanks for this great plugin!