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.
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?
- 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?
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?
Re: Has anybody done anything with Sensibo Sky?
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']) - 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?
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.
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)
Re: Has anybody done anything with Sensibo Sky?
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.
- 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?
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.
- 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?
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
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}
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
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 49 times
Re: Has anybody done anything with Sensibo Sky?
The first part, getting the list doesn't really send back anytyhing but the API key:
And when I tried --set-temp, I got this:
I'm sure I'm doing something wrong...
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 decodedCode: 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- 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?
oooops heh.. they are '-''s not '_'s my typo. sorry!!!!
- 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?
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.
Re: Has anybody done anything with Sensibo Sky?
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
Last edited by Mastiff on Fri Feb 09, 2018 5:51 pm, edited 1 time in total.
- 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?
This is still not going to work. but it will print out the error for me.
- Attachments
-
- test.py
- (13.05 KiB) Downloaded 39 times
- 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?
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
- 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?
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
- 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?
and this is actually not a correct command because you did not tell it what device you want to turn on.
it should be this
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
Code: Select all
"c:\program files (x86)\eventghost\py" test.py APIKEY --set-power on
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
Re: Has anybody done anything with Sensibo Sky?
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.
It's adding %7B to the beginning, and and it adds %7D to the end.
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