apetrycki / daikinskyport

API for accessing a DaikinOne+ Thermostat
63 stars 27 forks source link

Potential uint16 overflow power sensor value from the API #114

Open yuliwilliam opened 5 months ago

yuliwilliam commented 5 months ago

The indoor and outdoor power sensors occasionally report the values 65535 and 655350, which correspond to 2^16. These incorrect values are consistently received simultaneously from both sensors while my unit is operating. I suspect this issue is due to an overflow in the API.

Screenshot 2024-05-14 at 14 57 48 Screenshot 2024-05-14 at 14 57 57
apetrycki commented 5 months ago

I thought I filtered those out. Maybe it was a different sensor. Should be an easy fix.

yuliwilliam commented 5 months ago

this seems to happen every time the thermostat restarted.

apetrycki commented 5 months ago

in your sensor.py file, try modifying async_update like this and let me know if that works:

    async def async_update(self):
        """Get the latest state of the sensor."""
        await self.data._async_update_data()
        sensors = self.data.daikinskyport.get_sensors(self._index)
        for sensor in sensors:
            if sensor["type"] == self._type and self._sensor_name == sensor["name"]:
                if not sensor["value"] == 65535 and not sensor["value"] == 655350:
                    self._state = sensor["value"]
yuliwilliam commented 5 months ago

Thanks! I was away for a bit, let me find some time to test it out.

soul4soul commented 5 months ago

looks like you guys already have a handle on it but figured I mentioned I'm seeing the issue as well.

image

apetrycki commented 5 months ago

Try the fix I posted and let me know if it works. I don't have the sensors since my unit doesn't track power.

knightjoel commented 5 months ago
    async def async_update(self):
        """Get the latest state of the sensor."""
        await self.data._async_update_data()
        sensors = self.data.daikinskyport.get_sensors(self._index)
        for sensor in sensors:
            if sensor["type"] == self._type and self._sensor_name == sensor["name"]:
                if not sensor["value"] == 65535 and not sensor["value"] == 655350:
                    self._state = sensor["value"]

I've experienced some additional "infinite" values for certain sensors. I've been running with this commit in my fork for quite a while:

                # Manage values that indidcate a comms failure to the hardware.
                # Correct these values to something that doesn't skew the
                # graphs so badly.
                if (sensor["type"] in ("actual_status", "demand",
                                       "frequency_percent")
                        and sensor["value"] == 127.5):
                    self._state = None
                elif (sensor["type"] in ("power", "rpm")
                        and sensor["value"] == 65535):
                    self._state = None
                elif sensor["type"] == "temperature" and sensor["value"] == 255:
                    self._state = None
                else:
                    self._state = sensor["value"]
apetrycki commented 2 months ago

Is this still an issue?

knightjoel commented 2 months ago

Is this still an issue?

Would you consider the code I shared so that overflows in other sensors are caught as well?