Coder Social home page Coder Social logo

Comments (15)

smmoroz avatar smmoroz commented on June 9, 2024 1

I finally made two shell scripts to be integrated to HA

setdate.sh

#!/bin/zsh

user="USER"
password="PWD"
serial="SN"

rm -f cookie.txt

payload="{ \"smartphoneId\": \"pymultiMATIC\", \"username\": \"$user\", \"password\": \"$password\" }"
token=`curl -c cookie.txt -s -X POST -H "Content-Type:application/json" -H "Accept:application/json"  -d $payload 'https://smart.vaillant.com/mobile/api/v4/account/authentication/v1/token/new' | jq '.body.authToken'`
payload="{ \"smartphoneId\": \"pymultiMATIC\", \"username\": \"$user\", \"authToken\": $token }"
curl -b cookie.txt -c cookie.txt -X POST -H "Content-Type:application/json" -H "Accept:application/json"  -d $payload  "https://smart.vaillant.com/mobile/api/v4/account/authentication/v1/authenticate" 

payload="{ \"datetime\": \"`date +\"%FT%T.000Z\"`\"}"
#payload="{ \"datetime\": \"2021-06-08T18:00:00.000Z\"}"
url="https://smart.vaillant.com/mobile/api/v4/facilities/$serial/systemcontrol/v1/status/datetime"
curl -b cookie.txt -c cookie.txt -X PUT -H "Content-Type:application/json" -H "Accept:application/json"  -d $payload  $url

rm -f cookie.txt

and

getdate.sh

#!/bin/sh

user="USER"
password="PWD"
serial="SN"

rm -f cookie.txt

token=`curl -s -c cookie.txt -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{ "smartphoneId": "pymultiMATIC", "username": "'${user}'", "password": "'${password}'" }' 'https://smart.vaillant.com/mobile/api/v4/account/authentication/v1/token/new' | jq '.body.authToken'`

curl -s -b cookie.txt -c cookie.txt -X POST -H 'Content-Type:application/json' -H 'Accept:application/json' -d '{ "smartphoneId": "pymultiMATIC", "username": "'${user}'", "authToken": '${token}' }' 'https://smart.vaillant.com/mobile/api/v4/account/authentication/v1/authenticate' 

datetime=`curl -s -b cookie.txt -c cookie.txt -X GET -H 'Content-Type:application/json' -H 'Accept:application/json' 'https://smart.vaillant.com/mobile/api/v4/facilities/'${serial}'/systemcontrol/v1/status' | jq '.body.datetime'`

echo ${datetime}

rm -f cookie.txt

from vaillant-component.

thomasgermain avatar thomasgermain commented on June 9, 2024

Hello,

to me, this is the same kind of config that should not be included in the integration, this is not directly related to the platform used by the integration (fan, climate, water_heater, etc).

Maybe another option would be to create a script and the trigger it when you want via an automation ?

from vaillant-component.

smmoroz avatar smmoroz commented on June 9, 2024

There is already a service 'multimatic.request_hvac_update'. Why isn't it possible to add something like 'multimatic.set_date_time' service? BTW, I don't even know if such API call exists.

Of course it will be called manually or by some trigger.

from vaillant-component.

thomasgermain avatar thomasgermain commented on June 9, 2024

request_hvac_update is needed in some case to refresh data (some users reported their data were not getting updated).

From technical point of view, there is no problem adding a set_date_time service, this is more a scope problem. I don't want to add every single configuration possibilities available in the app or on the VRC700 (also, my end goal is to have the integration included in HA core, and I'm quite sure this kind of service won't pass the code review), this is why I proposed you to have a small script to the datetime and triggered it via automation

from vaillant-component.

smmoroz avatar smmoroz commented on June 9, 2024

Thomas, got it. I'm fine to use the script to set the date/time. Can you please share such script?

from vaillant-component.

thomasgermain avatar thomasgermain commented on June 9, 2024

I don't have a script right now, but I could do that

from vaillant-component.

smmoroz avatar smmoroz commented on June 9, 2024

It would be great! Looking forward to get it!

As for making this a general feature of the component, without NTP-like date/time setting the whole Vaillant hardware is more or less useless, because the time schedule only works if date/time is properly set. So, one can that this is an essential feature for your component. I believe it will be accepted by HA core team.

This feature, e.g. automatic update of date/time, could be deeply integrated into component and could be turned on/off via component option.

from vaillant-component.

smmoroz avatar smmoroz commented on June 9, 2024

Hi, Thomas,

I played a little bit with Vaillant API using pymultiMATIC as a source of information. I found only one place with facility date/time information here https://smart.vaillant.com/mobile/api/v4/facilities/_serialNumber_/system/v1/details. In my case the response is like this:

"body":{
  "facilityDetails":{
    "facilityName": "NAME",
    "facilityTime": "2021-06-08T19:49:35.986Z",
    "facilityTimeZone": "Europe/Moscow"
  }
},
"meta":{}

But facilities_details() is not reference anywhere in the code. So, it was not clear for me, if it is possible to modify facilityTime.

I tried PUT method with https://smart.vaillant.com/mobile/api/v4/facilities/_serialNumber_/system/v1/details with this payload:

{
  "facilityName": "NAME",
  "facilityTime": "2021-06-07T19:00:00.000Z",
  "facilityTimeZone": "Europe/Moscow"
}

It doesn't work. The response is HTTP Status 405 – Method Not Allowed.

I also found that date/time information is available here: https://smart.vaillant.com/mobile/api/v4/facilities/_serialNumber_/systemcontrol/v1/status. Here is the response:

"body":{
  "datetime": "2021-06-08T20:22:28.000Z",
  "outside_temperature": 19.4
}

But it is also not possible to set this datetime.

from vaillant-component.

smmoroz avatar smmoroz commented on June 9, 2024

I have finally found the right endpoint:

https://smart.vaillant.com/mobile/api/v4/facilities/_serialNumber_/systemcontrol/v1/status/datetime

PUT method works here with this payload

{
  "datetime": "2021-06-08T18:00:00.000Z"
}

I will now try to write Python script.

from vaillant-component.

thomasgermain avatar thomasgermain commented on June 9, 2024

can I close the issue ?

from vaillant-component.

smmoroz avatar smmoroz commented on June 9, 2024

Yes!

from vaillant-component.

smmoroz avatar smmoroz commented on June 9, 2024

Hi, Thomas,

Let me come back to this issue. Recently I've updated multimatic component to 1.7.1. And now I see a lot of errors likes this:

2021-08-18 11:34:27 ERROR (MainThread) [custom_components.multimatic.coordinator] Unexpected error fetching multimatic_quick_mode data: Unable to authenticate at https://smart.vaillant.com/mobile/api/v4/account/authentication/v1/authenticate

I'm pretty sure that this is because my get/set date scripts interfere with multimatic component. Both scripts and component use the same login/password to login/authenticate. get_time script is executed every 5 minutes. And as far as I understand, it destroys multimatic component session/token.

What is the best way to overcome this problem? New user?

What if you reconsider adding get/set datatime service to your component?

from vaillant-component.

thomasgermain avatar thomasgermain commented on June 9, 2024

Hmm yeah, strange that it appears with 1.7.1, this is a minor change.

As you said, you could use a seperate user in order to avoid authentication issues.

from vaillant-component.

smmoroz avatar smmoroz commented on June 9, 2024

Thomas, I have migrated from 1.5.0 to 1.7.1. It was a big update for me ;) So, no worries.

from vaillant-component.

xrado avatar xrado commented on June 9, 2024

@smmoroz I'm having the same problem with time being reset. I've tried your script but doesn't work anymore. I'm getting {"errorCode":"INVALID_PARAMS"} on last call, when getting the time.

from vaillant-component.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.