thomasgermain / vr900-connector

MIT License
13 stars 1 forks source link

Variable system.outdoorTemperature stops refreshing #2

Closed RoadracerSLO closed 5 years ago

RoadracerSLO commented 5 years ago

When running in loop, variable system.outdoorTemperature stops refreshing.

`manager = VaillantSystemManager('user', 'pass') #####################################################

while True:
system = manager.get_system() print(system.outdoorTemperature) time.sleep(INTERVAL)`

thomasgermain commented 5 years ago

Hi,

i'm a bit surprise, because i'm using the connector with homeassistant.

Homeassistant is polling the connector every minutes and if the temperature changes, it logs it to a graph. See my graph for today: outdoortemp

How much is the interval ? I guess it should be something like 30min.

You can also try accessing the API directly with the connector like this (with the last 0.0.23 version)

from vr900connector.api import ApiConnector, constant
connector = ApiConnector('user', 'pass')
print(connector.get(constant.SYSTEM_CONTROL_URL + '/status'))

This will print you the raw json directly coming from vaillant API, something like this:

{
    "body": {
        "datetime": "2019-02-08T21:05:23.000Z",
        "outside_temperature": 9.3
    },
    "meta": {
        "resourceState": [
            {
                "state": "OUTDATED",
                "timestamp": 1549659971708,
                "link": {
                    "rel": "self",
                    "resourceLink": "/facilities/xxx/systemcontrol/v1/status"
                }
            }
        ]
    }
}

Hope it helps,

Thomas

RoadracerSLO commented 5 years ago

I noticed that outside temperature stayed the same (8,4). On VR700 it was 2°C. I restarted python script and got same value. I opened Vaillant app on phone and first got same value (8,4). After a minute it changed to 2. I installed module with pip install. Name: vr900-connector Version: 0.0.17 Summary: Connector to handle vaillant vr900/vr920 data Home-page: https://github.com/thomasgermain/vr900-connector.git Author: Thomas Germain

thomasgermain commented 5 years ago

You mean you also saw 8.4 on mobile app and than 2 ? Did you see the same with the script ? I guess there is a direct communication between VR700 and outdoor thermometer and the VR9xx has to push it to the API before it can get read by mobile app or the connector.

To install last version, you can just do

pip install vr900-connector --upgrade
RoadracerSLO commented 5 years ago

I think that VR9x0 expects some request for update. Because it updated after app request. I got the same value with the script. I updated module to 0.0.26 and dhw changed to hotWater. I miss variables description. I got my with trial&error.

RoadracerSLO commented 5 years ago

Running your script I got response: {'body': {'datetime': '2019-02-09T12:15:09.000Z', 'outside_temperature': 7.3}, 'meta': {'resourceState': [{'state': 'OUTDATED', 'timestamp': 1549710942568, 'link': {'rel': 'self', 'resourceLink': '/facilities/21181300202529260938012427N3/systemcontrol/v1/status'}}]}}

Commifreak commented 5 years ago

I think that VR9x0 expects some request for update. Because it updated after app request.

Thats indeed the fact. If I never open the app, the VR900 wont push anything to Vaillant servers. You can check that by open the app and go tone general settings where the time and date of the heating system appears. This shown date & time is the last sync time.

After the App opened, a few minutes later the values getting refreshed, so the App creates a job and the VR900 waits fo a new sync job. If it finds that, it collects all datas and pushes it to Vaillant.

This is annoying, yes but I got a "workaround": Since Im on iOS, I enabled the HEM widget. Everytime I open the Widget Area, the Widget loads the data and also creates a Collect-Job for the Vr900. Next time I open the App again, the datas are not that outdated.

RoadracerSLO commented 5 years ago

Is it possible to send request for refresh like app does? I want to get rid of app and make my own.

thomasgermain commented 5 years ago

Hey,

I don't have this kind of problem, as I said, I used the connector with homeassistant and data I received are moving as expected (when water heater is on, water temp is moving up, etc.)

What VR9XX do you have ? I have VR920, maybe it doesn't need some refresh query.

Anyway, I found that the application is calling events/v1 in background, maybe I can do the same

I'm trying a polling script and will let run this evening, and check if outdoor temp is moving

thomasgermain commented 5 years ago

I think that VR9x0 expects some request for update. Because it updated after app request. I got the same value with the script. I updated module to 0.0.26 and dhw changed to hotWater. I miss variables description. I got my with trial&error.

By the way, for some "doc" you can check model: https://github.com/thomasgermain/vr900-connector/tree/develop/vr900connector/model

thomasgermain commented 5 years ago

So, I tried. I disconnect from the (android app) so I hope there is background call to "wake up" the VR900.

So far, everything seems to work as expected. (Temperature is moving a bit and it is the same as on my VR700).

@RoadracerSLO, @Commifreak May I ask you to test this little script and let it run for a few hours so I can check ? (It only logs current time, last update and current outdoor temp to a file). You can put more than 1 minute if you want, it's just to be sure that outdoor temps is not moving. Thanks in advance !

import datetime
import time
from vr900connector.api import ApiConnector, constant

connector = ApiConnector('user', 'pass')
while True:
    with open('outdoor-temp.txt', 'a+') as file:
        response = connector.get(constant.SYSTEM_CONTROL_URL + '/status')['body']
        last_update = response['datetime']
        temp = response['outside_temperature']
        file.write('at {} temp is {} and last_update is {}\n'.format(datetime.datetime.now(), temp, last_update))
    time.sleep(1*60)
RoadracerSLO commented 5 years ago

image I updated and tested. Issue didn't happened again.

thomasgermain commented 5 years ago

Nice :)