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
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 »

Anything pre rc4 should work.

I haven't used pycurl before but this may work in rc4+ versions. Worth a shot.

Code: Select all

import pycurl
from StringIO import StringIO
key = ' ' 
baseUrl = 'https://home.sensibo.com/api/v2'
cmd = '/users/me/pods'

buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, baseUrl + cmd + '?' + 'apiKey=' + key + '&fields=id,room')
c.setopt(c.WRITEDATA, buffer)
c.perform()
c.close()

body = buffer.getvalue()
print(body)
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Has anybody done anything with Sensibo Sky?

Post by Mastiff »

Seems like there's less and less error lines. Is that a good sign?

Code: Select all

21:49:36      Traceback (most recent call last):
21:49:36        Python script "214", line 11, in <module>
21:49:36          c.perform()
21:49:36      error: (60, 'SSL certificate problem: unable to get local issuer certificate')
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 looks like the same kind of error. It's having problems finding the ssl certs on windows. Try the first one on pre rc4 if you can
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Has anybody done anything with Sensibo Sky?

Post by Mastiff »

Here's the output of the 0.4 version (which seems to work):

Code: Select all

21:54:11         {u'status': u'success', u'result': [{u'id': u'oohZomrQ', u'room': {u'name': u'Varmepumpe ovenp\xe5', u'icon': u'bedroom'}}]}
In unicode it should be "Varmepumpe ovenpå", but it's the correct place. :mrgreen:
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 »

Beautiful, I'll get a few more of the commands going now that I can see what it's returning.
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Has anybody done anything with Sensibo Sky?

Post by Mastiff »

Great, thanks! And who should I pester to fix that SSL problem? :mrgreen:
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 think kg fixed it. It just started working for me one day when i reinstalled rc4, when it previously didn't. Give these a shot, it's xml not just one script.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc4">
    <Macro Name="Sensibo" XML_Guid="{351D723D-8A39-4611-B268-78D2FF9F7087}" Expanded="True">
        <Action Name="add your api key to the first script, nothing else needs editing." XML_Guid="{C4221FD5-5685-4E3C-8BF2-8FA0A3897FEB}">
            EventGhost.Comment()
        </Action>
        <Action Name="get/set global device variables" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u"import requests\nimport json\n\n# Enter your api key\neg.globals.sensiboKey = ''\n\nparams = {}\nparams['apiKey'] = eg.globals.sensiboKey\nparams['fields'] = 'id,room'\n\n# command paths\nbaseUrl = 'https://home.sensibo.com/api/v2'\ndevices = '/users/me/pods'\nmeasurement = '/pods/%s/measurements'\nstate = '/pods/%s/acStates'\nchangeState = '/pods/%s/acStates/%s'\n\n# First request to get devices/id\nresponse = requests.get(baseUrl + devices, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\neg.globals.sensiboDeviceName1 = deviceDict['result'][0]['room']['name']\neg.globals.sensiboDeviceId1 = deviceDict['result'][0]['id']\n\nprint eg.globals.sensiboDeviceName1\nprint eg.globals.sensiboDeviceId1\n\n\n")
        </Action>
        <Action Name="get device measurement" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u"import requests\nimport json\n\nparams = {}\nparams['apiKey'] = eg.globals.sensiboKey\nparams['podUid'] = eg.globals.sensiboDeviceId1\n\n# command paths\nbaseUrl = 'https://home.sensibo.com/api/v2'\ndevices = '/users/me/pods'\nmeasurement = '/pods/%s/measurements'\nstate = '/pods/%s/acStates'\nchangeState = '/pods/%s/acStates/%s'\n\n# First request to get devices/id\nresponse = requests.get(baseUrl + measurement, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\nprint deviceDict\n\n\n\n")
        </Action>
        <Action Name="get device state" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u'import requests\nimport json\n\nparams = {}\nparams[\'apiKey\'] = eg.globals.sensiboKey\nparams[\'podUid\'] = eg.globals.sensiboDeviceId1\nparams[\'limit\'] = 1\nparams[\'fields\'] = "status,reason,acState"\n\n# command paths\nbaseUrl = \'https://home.sensibo.com/api/v2\'\ndevices = \'/users/me/pods\'\nmeasurement = \'/pods/%s/measurements\'\nstate = \'/pods/%s/acStates\'\nchangeState = \'/pods/%s/acStates/%s\'\n\n# First request to get devices/id\nresponse = requests.get(baseUrl + state, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\nprint deviceDict\n\n\n\n')
        </Action>
    </Macro>
</EventGhost>
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Has anybody done anything with Sensibo Sky?

Post by Mastiff »

Thanks, I have opened a thread in the beta forum asking for a fix for a WIP version.

So the first code gave me this:

Code: Select all

08:27:52      Varmepumpe ovenpå
08:27:52      oohZomrQ
Correct letters and all in the first one. :mrgreen: The two others gave me this:

Code: Select all

08:31:58      Traceback (most recent call last):
08:31:58        Python script "231", line 18, in <module>
08:31:58          deviceDict = json.loads(jString)
08:31:58        File "json\__init__.pyc", line 307, in loads
08:31:58        File "json\decoder.pyc", line 319, in decode
08:31:58        File "json\decoder.pyc", line 338, in raw_decode
08:31:58      ValueError: No JSON object could be decoded
Is this a missing plug-in in my setup, or something? I have the HTTPRequest plug-in, but maybe it's another plug-in with JSON?
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 »

Json is formatting, like Unicode. Your not missing anything. I just made an error somewhere & there wasn't a response for it to decode. I didn't add any error handling to the scripts. I'll take a closer look in the morning.
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Has anybody done anything with Sensibo Sky?

Post by Mastiff »

Great, thanks! It has to be pretty late there now. But I guess the SuperBowl adrenaline takes a bit of time to wind down... :mrgreen:
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 didn't actually watch it. I just keep weird hours. I think i see what i did wrong. I didn't insert the podUid variable into the commands. Give these a shot, if they're okay i'll work on the last command to set the device states.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc4">
    <Macro Name="Sensibo" XML_Guid="{351D723D-8A39-4611-B268-78D2FF9F7087}" Expanded="True">
        <Action Name="add your api key to the first script, nothing else needs editing." XML_Guid="{C4221FD5-5685-4E3C-8BF2-8FA0A3897FEB}">
            EventGhost.Comment()
        </Action>
        <Action Name="get/set global device variables" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u"import requests\nimport json\n\n# Enter your api key\neg.globals.sensiboKey = ''\n\nparams = {}\nparams['apiKey'] = eg.globals.sensiboKey\nparams['fields'] = 'id,room'\n\n# command paths\nbaseUrl = 'https://home.sensibo.com/api/v2'\ndevices = '/users/me/pods'\n\n\n# First request to get devices/id\nresponse = requests.get(baseUrl + devices, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\neg.globals.sensiboDeviceName1 = deviceDict['result'][0]['room']['name']\neg.globals.sensiboDeviceId1 = deviceDict['result'][0]['id']\n\nprint eg.globals.sensiboDeviceName1\nprint eg.globals.sensiboDeviceId1\n\n\n")
        </Action>
        <Action Name="get device measurement" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u"import requests\nimport json\n\nparams = {}\nparams['apiKey'] = eg.globals.sensiboKey\n\n# command paths\nbaseUrl = 'https://home.sensibo.com/api/v2'\ndevices = '/users/me/pods'\nmeasurement = '/pods/' + eg.globals.sensiboDeviceId1 + '/measurements'\nstate = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates'\nchangeState = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'property to change'\n\n# First request to get devices/id\nresponse = requests.get(baseUrl + measurement, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\nprint deviceDict\n\n\n\n")
        </Action>
        <Action Name="get device state" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u'import requests\nimport json\n\nparams = {}\nparams[\'apiKey\'] = eg.globals.sensiboKey\nparams[\'limit\'] = 1\nparams[\'fields\'] = "status,reason,acState"\n\n# command paths\nbaseUrl = \'https://home.sensibo.com/api/v2\'\ndevices = \'/users/me/pods\'\nmeasurement = \'/pods/\' + eg.globals.sensiboDeviceId1 + \'/measurements\'\nstate = \'/pods/\' + eg.globals.sensiboDeviceId1 + \'/acStates\'\nchangeState = \'/pods/\' + eg.globals.sensiboDeviceId1 + \'/acStates/\' + \'property to change\'\n\n\n# First request to get devices/id\nresponse = requests.get(baseUrl + state, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\nprint deviceDict\n\n\n\n')
        </Action>
    </Macro>
</EventGhost>
Mastiff
Experienced User
Posts: 872
Joined: Thu May 03, 2012 10:43 am

Re: Has anybody done anything with Sensibo Sky?

Post by Mastiff »

Oh, I thought it was unamerican not to watch it, punishable by two hours of DT telling you how great and beautiful the wall will be... :lol:

OK, that worked! I must say I'm impressed by the presicion of temp and humidity:

Code: Select all

21:09:53      {u'status': u'success', u'result': [{u'humidity': 25.699999999999999, u'temperature': 21.199999999999999, u'time': {u'secondsAgo': 31, u'time': u'2018-02-05T20:09:18.188000Z'}}]}

Code: Select all

21:11:43      {u'status': u'success', u'moreResults': True, u'result': [{u'status': u'Success', u'acState': {u'on': True, u'fanLevel': u'auto', u'temperatureUnit': u'C', u'targetTemperature': 22, u'mode': u'heat', u'swing': u'rangeFull'}, u'reason': u'UserRequest'}]}
It seems it takes the necessary stuff out. :mrgreen:
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 if you want to use requests the SSL error has a fix for it. located HERE I have sent to code in to fix the problem . For the time being you can do the second fix that i described and it should work.
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 »

I was actually about to write that! :mrgreen: Thanks again!
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 »

The last bit was hard to decipher. I hope these work. Try the other older scripts too, i changed them to generate events.

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="0.5.0-rc4">
    <Macro Name="Sensibo" XML_Guid="{351D723D-8A39-4611-B268-78D2FF9F7087}" Expanded="True">
        <Action Name="add your api key to the first script, nothing else needs editing." XML_Guid="{C4221FD5-5685-4E3C-8BF2-8FA0A3897FEB}">
            EventGhost.Comment()
        </Action>
        <Action Name="get/set global device variables" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u"import requests\nimport json\n\n# Enter your api key\neg.globals.sensiboKey = ''\n\nparams = {}\nparams['apiKey'] = eg.globals.sensiboKey\nparams['fields'] = 'id,room'\n\n# command paths\nbaseUrl = 'https://home.sensibo.com/api/v2'\ndevices = '/users/me/pods'\n\n\n# First request to get devices/id\nresponse = requests.get(baseUrl + devices, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\neg.globals.sensiboDeviceName1 = deviceDict['result'][0]['room']['name']\neg.globals.sensiboDeviceId1 = deviceDict['result'][0]['id']\n\nprint eg.globals.sensiboDeviceName1\nprint eg.globals.sensiboDeviceId1\n\n\n")
        </Action>
        <Action Name="get device measurement" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u'import requests\nimport json\n\nparams = {}\nparams[\'apiKey\'] = eg.globals.sensiboKey\nsensiboCurrentDict = {}\n\n# command paths\nbaseUrl = \'https://home.sensibo.com/api/v2\'\ndevices = \'/users/me/pods\'\nmeasurement = \'/pods/\' + eg.globals.sensiboDeviceId1 + \'/measurements\'\nstate = \'/pods/\' + eg.globals.sensiboDeviceId1 + \'/acStates\'\nchangeState = \'/pods/\' + eg.globals.sensiboDeviceId1 + \'/acStates/\' + \'property to change\'\n\nresponse = requests.get(baseUrl + measurement, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\neg.globals.sensiboLastMeasurement = deviceDict[\'result\'][0]\n\neg.TriggerEvent(prefix="Sensibo", suffix=eg.globals.sensiboDeviceName1, payload=eg.globals.sensiboLastMeasurement)\n\n\n\n')
        </Action>
        <Action Name="get device state" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u'import requests\nimport json\n\nparams = {}\nparams[\'apiKey\'] = eg.globals.sensiboKey\nparams[\'limit\'] = 1\nparams[\'fields\'] = "status,reason,acState"\n\n# command paths\nbaseUrl = \'https://home.sensibo.com/api/v2\'\ndevices = \'/users/me/pods\'\nmeasurement = \'/pods/\' + eg.globals.sensiboDeviceId1 + \'/measurements\'\nstate = \'/pods/\' + eg.globals.sensiboDeviceId1 + \'/acStates\'\nchangeState = \'/pods/\' + eg.globals.sensiboDeviceId1 + \'/acStates/\' + \'property to change\'\n\n\n# First request to get devices/id\nresponse = requests.get(baseUrl + state, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\neg.globals.sensiboLastState = deviceDict[\'result\'][0][\'acState\']\n\n\neg.TriggerEvent(prefix="Sensibo", suffix=eg.globals.sensiboDeviceName1, payload=eg.globals.sensiboLastState)\n\n\n\n\n')
        </Action>
        <Action Name="set Temp" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u"import requests\nimport json\n\n# change this value.  If this errors, try '20'.\nsetTemp = 20\n\nparams = {}\nparams['apiKey'] = eg.globals.sensiboKey\nparams['targetTemperature'] = setTemp\n\n# command paths\nbaseUrl = 'https://home.sensibo.com/api/v2'\ndevices = '/users/me/pods'\nmeasurement = '/pods/' + eg.globals.sensiboDeviceId1 + '/measurements'\nstate = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates'\nsetTemperature = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'targetTemperature'\nsetOnOff = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'on'\nsetMode = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'mode'\nsetFan = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'fanLevel'\n\n\n# First request to get devices/id\nresponse = requests.patch(baseUrl + setTemperature, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\nprint deviceDict\n\n\n\n")
        </Action>
        <Action Name="set Mode" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u"import requests\nimport json\n\n# change this value, i think the other setting will be 'cooling'.\nmode = 'heat'\n\nparams = {}\nparams['apiKey'] = eg.globals.sensiboKey\nparams['mode'] = mode\n\n# command paths\nbaseUrl = 'https://home.sensibo.com/api/v2'\ndevices = '/users/me/pods'\nmeasurement = '/pods/' + eg.globals.sensiboDeviceId1 + '/measurements'\nstate = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates'\nsetTemperature = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'targetTemperature'\nsetOnOff = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'on'\nsetMode = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'mode'\nsetFan = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'fanLevel'\n\n\n# First request to get devices/id\nresponse = requests.patch(baseUrl + setMode, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\nprint deviceDict\n\n\n\n")
        </Action>
        <Action Name="set Fan" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u"import requests\nimport json\n\n# change this value, i think settings will be 'auto', 'on', 'off'.\nfanSet = 'auto'\n\nparams = {}\nparams['apiKey'] = eg.globals.sensiboKey\nparams['fanLevel'] = fanSet\n\n# command paths\nbaseUrl = 'https://home.sensibo.com/api/v2'\ndevices = '/users/me/pods'\nmeasurement = '/pods/' + eg.globals.sensiboDeviceId1 + '/measurements'\nstate = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates'\nsetTemperature = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'targetTemperature'\nsetOnOff = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'on'\nsetMode = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'mode'\nsetFan = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'fanLevel'\n\n\n# First request to get devices/id\nresponse = requests.patch(baseUrl + setFan, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\nprint deviceDict\n\n\n\n")
        </Action>
        <Action Name="set On/Off" XML_Guid="{BEEED31A-C7AF-4080-86CE-5E828329911F}">
            EventGhost.PythonScript(u"import requests\nimport json\n\n# change this value, True, False.\nonOff = 'False'\n\nparams = {}\nparams['apiKey'] = eg.globals.sensiboKey\nparams['on'] = onOff\n\n# command paths\nbaseUrl = 'https://home.sensibo.com/api/v2'\ndevices = '/users/me/pods'\nmeasurement = '/pods/' + eg.globals.sensiboDeviceId1 + '/measurements'\nstate = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates'\nsetTemperature = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'targetTemperature'\nsetOnOff = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'on'\nsetMode = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'mode'\nsetFan = '/pods/' + eg.globals.sensiboDeviceId1 + '/acStates/' + 'fanLevel'\n\n\n# First request to get devices/id\nresponse = requests.patch(baseUrl + setOnOff, params = params)\njString = response.content\ndeviceDict = json.loads(jString)\n\nprint deviceDict\n\n\n\n")
        </Action>
    </Macro>
</EventGhost>
Post Reply