lostfields / python-panasonic-comfort-cloud

A python module for reading and changing status of panasonic climate devices through Panasonic Comfort Cloud app api
MIT License
69 stars 40 forks source link

pcomfortcloud/session.py#L221 history data offset by 9 hrs - tz hardcoded to +0100 #55

Open purcell-lab opened 3 years ago

purcell-lab commented 3 years ago

Noticed my history dump for hourly and daily consumption values were 'odd', turns out they were offset by 9hrs..

Suspecting a TZ issue, I found line 221 in session.py

https://github.com/lostfields/python-panasonic-comfort-cloud/blob/18d49855239504bbbf49f15352e0a89f44cb41c2/pcomfortcloud/session.py#L221

Changing to my timezone (tz="+10:00") seems to of fixed the offset issue for me.

It would be better for session.py to set tz from the host system, rather than using a hardcoded value.

Thanks

lostfields commented 3 years ago

Hi, how are you using this library?

purcell-lab commented 3 years ago

I have been using it though Home Assistant, but get the same results using the command line pcomfortcloud from your library.

Mark

purcell-lab commented 2 years ago

This issue is still causing me problems.

Some further detail below, it is just after 11pm here, heating was switched on after 9pm and should expose consumption from that time.

When run as distributed with hardcoded Line221 tz="+01:00":

When run with modified Line221 tz="+11:00", reflecting my timezone:

Why is the tz variable at Line221 hardcoded to +01:00 and is it possible to automatically set tz to the current system time, in my case +11:00?

Output below:

mark@penguin:~$ date -R
Tue, 23 Nov 2021 23:12:41 +1100
mark@penguin:~$ grep tz= .local/lib/python3.7/site-packages/pcomfortcloud/session.py 
    def history(self, id, mode, date, tz="+01:00"):
mark@penguin:~$ .local/bin/pcomfortcloud $PUSER $PPASS history 1 Day 20211123 
id                       : 403955336a130ea12f8b436cac9ced90bff4d1513a0d5ba46e06c951f634a0cc
parameters
    currencyUnit         : $
    energyConsumption    : 2.4
    estimatedCost        : 0.0
    historyDataList      :
        dataNumber       : 0
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 15.5

        dataNumber       : 1
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 17.0

        dataNumber       : 2
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.75
        averageOutsideTemp: 18.0

        dataNumber       : 3
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 16.0
        averageOutsideTemp: 19.75

        dataNumber       : 4
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 16.75
        averageOutsideTemp: 20.0

        dataNumber       : 5
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 17.25
        averageOutsideTemp: 20.5

        dataNumber       : 6
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 18.0
        averageOutsideTemp: 20.5

        dataNumber       : 7
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 18.0
        averageOutsideTemp: 20.0

        dataNumber       : 8
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 18.0
        averageOutsideTemp: 19.75

        dataNumber       : 9
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 18.0
        averageOutsideTemp: 19.0

        dataNumber       : 10
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.5
        averageInsideTemp: 18.0
        averageOutsideTemp: 17.75

        dataNumber       : 11
        consumption      : 0.1
        cost             : 0.0
        averageSettingTemp: 20.0
        averageInsideTemp: 20.25
        averageOutsideTemp: 16.75

        dataNumber       : 12
        consumption      : 2.3
        cost             : 0.0
        averageSettingTemp: 20.0
        averageInsideTemp: 19.25
        averageOutsideTemp: 16.75

        dataNumber       : 13
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

        dataNumber       : 14
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

        dataNumber       : 15
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

        dataNumber       : 16
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

        dataNumber       : 17
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        return self._devices
        averageOutsideTemp: -255

        dataNumber       : 18
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

        dataNumber       : 19
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

        dataNumber       : 20
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

        dataNumber       : 21
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

        dataNumber       : 22
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

        dataNumber       : 23
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

My edited version:

mark@penguin:~$ vi +221 .local/lib/python3.7/site-packages/pcomfortcloud/session.py 
mark@penguin:~$ date -R
Tue, 23 Nov 2021 23:13:25 +1100
mark@penguin:~$ grep tz= .local/lib/python3.7/site-packages/pcomfortcloud/session.py 
    def history(self, id, mode, date, tz="+11:00"):
mark@penguin:~$ .local/bin/pcomfortcloud $PUSER $PPASS history 1 Day 20211123 
id                       : 403955336a130ea12f8b436cac9ced90bff4d1513a0d5ba46e06c951f634a0cc
parameters
    currencyUnit         : $
    energyConsumption    : 2.4
    estimatedCost        : 0.0
    historyDataList      :
        dataNumber       : 0
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 14.75
        averageOutsideTemp: 12.0

        dataNumber       : 1
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 12.0

        dataNumber       : 2
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 12.0

        dataNumber       : 3
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 12.25

        dataNumber       : 4
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 12.5

        dataNumber       : 5
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 12.5

        dataNumber       : 6
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 13.0

        dataNumber       : 7
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 13.5

        dataNumber       : 8
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 14.25

        dataNumber       : 9
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 15.0

        dataNumber       : 10
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 15.5

        dataNumber       : 11
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.0
        averageOutsideTemp: 17.0

        dataNumber       : 12
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 15.75
        averageOutsideTemp: 18.0

        dataNumber       : 13
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 16.0
        averageOutsideTemp: 19.75

        dataNumber       : 14
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 16.75
        averageOutsideTemp: 20.0

        dataNumber       : 15
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 17.25
        averageOutsideTemp: 20.5

        dataNumber       : 16
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 18.0
        averageOutsideTemp: 20.5

        dataNumber       : 17
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 18.0
        averageOutsideTemp: 20.0

        dataNumber       : 18
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 18.0
        averageOutsideTemp: 19.75

        dataNumber       : 19
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.0
        averageInsideTemp: 18.0
        averageOutsideTemp: 19.0

        dataNumber       : 20
        consumption      : 0.0
        cost             : 0.0
        averageSettingTemp: 18.5
        averageInsideTemp: 18.0
        averageOutsideTemp: 17.75

        dataNumber       : 21
        consumption      : 0.1
        cost             : 0.0
        averageSettingTemp: 20.0
        averageInsideTemp: 20.25
        averageOutsideTemp: 16.75

        dataNumber       : 22
        consumption      : 2.3
        cost             : 0.0
        averageSettingTemp: 20.0
        averageInsideTemp: 19.25
        averageOutsideTemp: 16.75

        dataNumber       : 23
        consumption      : -255
        cost             : -255
        averageSettingTemp: -255
        averageInsideTemp: -255
        averageOutsideTemp: -255

mark@penguin:~$ .local/bin/pcomfortcloud $PUSER $PPASS list
list of devices and its device id (1-x)
device #1
    id                   : 403955336a130ea12f8b436cac9ced90bff4d1513a0d5ba46e06c951f634a0cc
    name                 : Panasonic
    group                : My House
    model                : S-180PE3R5B
mark@penguin:~$ .local/bin/pcomfortcloud $PUSER $PPASS get 1
reading from device 'Panasonic' (403955336a130ea12f8b436cac9ced90bff4d1513a0d5ba46e06c951f634a0cc)
id                       : 403955336a130ea12f8b436cac9ced90bff4d1513a0d5ba46e06c951f634a0cc
parameters
    temperatureInside    : 21
    temperatureOutside   : 16
    temperature          : 20.0
    power                : On
    mode                 : Heat
    fanSpeed             : Auto
    airSwingHorizontal   : Mid
    airSwingVertical     : DownMid
    eco                  : Auto
    nanoe                : Unavailable