Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Has anybody done anything with Sensibo Sky?

If you have a question or need help, this is the place to be.
Post Reply
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

the patch method does not work. from browsing the information and code I could find post is used and not patch. have you tried the script they provided as is?
If you like the work I have been doing then feel free to Image
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Has anybody done anything with Sensibo Sky?

Post by yokel22 »

I'm not sure what your looking at. This is the sample client. It would need only slight modification to work within an eg script. It would be faster to insert into a plugin though.

Code: Select all

import requests
import json

_SERVER = 'https://home.sensibo.com/api/v2'

class SensiboClientAPI(object):
    def __init__(self, api_key):
        self._api_key = api_key

    def _get(self, path, ** params):
        params['apiKey'] = self._api_key
        response = requests.get(_SERVER + path, params = params)
        response.raise_for_status()
        return response.json()

    def _patch(self, path, data, ** params):
        params['apiKey'] = self._api_key
        response = requests.patch(_SERVER + path, params = params, data = data)
        response.raise_for_status()
        return response.json()

    def devices(self):
        result = self._get("/users/me/pods", fields="id,room")
        return {x['room']['name']: x['id'] for x in result['result']}

    def pod_measurement(self, podUid):
        result = self._get("/pods/%s/measurements" % podUid)
        return result['result']

    def pod_ac_state(self, podUid):
        result = self._get("/pods/%s/acStates" % podUid, limit = 1, fields="status,reason,acState")
        return result['result'][0]['acState']

    def pod_change_ac_state(self, podUid, currentAcState, propertyToChange, newValue):
        self._patch("/pods/%s/acStates/%s" % (podUid, propertyToChange),
                json.dumps({'currentAcState': currentAcState, 'newValue': newValue}))

if __name__ == "__main__":
    import argparse
    parser = argparse.ArgumentParser(description='Sensibo client example parser')
    parser.add_argument('apikey', type = str)
    parser.add_argument('deviceName', type = str)
    args = parser.parse_args()

    client = SensiboClientAPI(args.apikey)
    devices = client.devices()
    print "-" * 10, "devices", "-" * 10
    print devices

    uid = devices[args.deviceName]
    ac_state = client.pod_ac_state(uid)
    print "-" * 10, "AC State of %s" % args.deviceName, "_" * 10
    print ac_state

    client.pod_change_ac_state(uid, ac_state, "on", not ac_state['on']) 
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

I know of their example, But there are other people who have written bits of software to connect to these things. and not a single one of them use the patch method. I would guess this is because it is problematic?, IDK. I am able to find libraries made on several different programming languages. but only the one for python.


This can be tried to see if it works. I believe it should.

Code: Select all

import requests
import json

data = dict(
    on='on',
    mode='heat',
    targetTemperature=27,
    temperatureUnit='celsius',
    swing='rangeFull',
    fanLevel='medium_high'
)

params = dict(
    apiKey=eg.globals.sensiboKey,
    fields="acState"
)

response = requests.post(
    'https://home.sensibo.com/api/v2/pods/oohZomrQ/acStates', 
    data=json.dumps(data),
    params=params
)

print response.content
print json.dumps(response.json(), indent=4)
If you like the work I have been doing then feel free to Image
User avatar
yokel22
Experienced User
Posts: 265
Joined: Thu Feb 05, 2015 5:56 pm
Location: U.S. - Kansas city

Re: Has anybody done anything with Sensibo Sky?

Post by yokel22 »

That will likely work. I don't think patch would be a problem either. It was the way i was formatting the data. Seeing that example shows me where my error was.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

I didn't look to close at the patch method. But at a glance what you had done looked the same as in the example they gave. Not sure tho.
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

ok you can give this a try. I have attached a file that is a python file. you can run this without installing python. (well you actually already have it installed.

This has to be done using EG 0.5

Download the file
open a command prompt
navigate to where you saved the file.

if you have EG installed in it's normal location enter this command, or modify it's path accordingly.

replace the {api_key} with your api key

Code: Select all

"c:\program files (x86)\eventghost\_py" test.py {api_key} --list-devices
The api key always has to be there. if you want to print out the device information add the --device-name {name} switch

command line switches are listed below. any of the options that have set in them you will need to make sure that you enter the appropriate item from the device capabilities that gets printed out. EXCEPT for set-power, use on or off for this switch

--list_devices
--device_name {DEVICE_NAME}
--set_temp {TARGET_TEMP}
--set_swing {SWING}
--set_power {POWER}
--set_mode {MODE}
--set_fan {FAN_LEVEL}
Attachments
test.py
(13.07 KiB) Downloaded 50 times
If you like the work I have been doing then feel free to Image
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Has anybody done anything with Sensibo Sky?

Post by Mastiff »

The first part, getting the list doesn't really send back anytyhing but the API key:

Code: Select all

D:\>"c:\program files (x86)\eventghost\py" test.py {My API key} --list-devices
{My API key}
None
True
None
None
None
None
None
---------- devices ----------
Traceback (most recent call last):
  File "py.py", line 29, in <module>
  File "D:\test.py", line 389, in <module>
    for dev in client.device_names:
  File "D:\test.py", line 328, in device_names
    return sorted(self.devices.keys())
  File "D:\test.py", line 342, in devices
    result = response.json()
  File "c:\program files (x86)\eventghost\lib27\site-packages\requests\models.py", line 812, in json
    return complexjson.loads(self.text, **kwargs)
  File "json\__init__.pyc", line 339, in loads
  File "json\decoder.pyc", line 364, in decode
  File "json\decoder.pyc", line 382, in raw_decode
ValueError: No JSON object could be decoded
And when I tried --set-temp, I got this:

Code: Select all

D:\>"c:\program files (x86)\eventghost\py" test.py {My API key} --set_temp {20}
usage: test.py [-h] [--list-devices] [--device-name DEVICE_NAME]
               [--set-temp SET_TEMP] [--set-swing SET_SWING]
               [--set-power SET_POWER] [--set-mode SET_MODE]
               [--set-fan SET_FAN]
               api_key
test.py: error: unrecognized arguments: --set_temp 20
I'm sure I'm doing something wrong...
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

oooops heh.. they are '-''s not '_'s my typo. sorry!!!!
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

but it is still not going to work..let me modify it so we can see hat the error is that it is spitting out.
If you like the work I have been doing then feel free to Image
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Has anybody done anything with Sensibo Sky?

Post by Mastiff »

:mrgreen: Well, the reaction changes, but it doesn't seem to affect the heat pump. I have tried temp and gotten this:

Code: Select all

D:\>"c:\program files (x86)\eventghost\py" test.py {My API key} --set-power {on}
{My API key}
None
False
None
None
{on}
None
None
And it's notpicking out the name, becuse the name is suposed to be Varmepumpe ovenpå, and then there's an UID (Probably Unit ID) that I can see in the web page of Sensibo, but that doesn't help (it only adds an extra line, with the ID). And the name fails, probably because of the "å" in it. Is it the UID that I actually should use, or is it the name, so I have to rename it to something with no special characters?
Last edited by Mastiff on Fri Feb 09, 2018 5:51 pm, edited 1 time in total.
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

This is still not going to work. but it will print out the error for me.
Attachments
test.py
(13.05 KiB) Downloaded 40 times
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

no curly braces {}... just on or off. but as i said. it is not going to work until i find out why it is not getting a device list
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

well that is probably why too. you are putting {}'s around your api key.. don't

Code: Select all

"c:\program files (x86)\eventghost\py" test.py APIKEY --set-power on
If you like the work I have been doing then feel free to Image
User avatar
kgschlosser
Site Admin
Posts: 5190
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Has anybody done anything with Sensibo Sky?

Post by kgschlosser »

and this is actually not a correct command because you did not tell it what device you want to turn on.

Code: Select all

"c:\program files (x86)\eventghost\py" test.py APIKEY --set-power on
it should be this

Code: Select all

"c:\program files (x86)\eventghost\py" test.py APIKEY --device-name DEVICENAME --set-power on

anything you want to do that is device specific you need to tell it the device.

to list the devices names then use the --list-devices with only your api key
If you like the work I have been doing then feel free to Image
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Has anybody done anything with Sensibo Sky?

Post by Mastiff »

As I said I tried with that too, but it didn't change anything. And I see why. It's not parsing the key correctly.

Code: Select all

<html><head><title>403 NotAuthorized - Sensibo</title></head><body><h>403 NotAuthorized</h><p>Invalid API key</p><body></html>
Traceback (most recent call last):
  File "py.py", line 29, in <module>
  File "D:\test.py", line 401, in <module>
    dev = getattr(client, args.device_name)
  File "D:\test.py", line 361, in __getattr__
    devices = self.devices
  File "D:\test.py", line 346, in devices
    response.raise_for_status()
  File "c:\program files (x86)\eventghost\lib27\site-packages\requests\models.py
", line 844, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://home.sensibo.com/api/v2/users/me/pods?fields=id%2Croom&apiKey=%7B[b]MY API KEY[/b]%7D
It's adding %7B to the beginning, and and it adds %7D to the end.
Post Reply