Add support for sensibo?

For heating/cooling related questions in Domoticz

Moderator: leecollings

Post Reply
olskar
Posts: 17
Joined: Sunday 12 February 2017 15:58
Target OS: -
Domoticz version:
Contact:

Add support for sensibo?

Post by olskar »

https://sensibo.zendesk.com/hc/en-us/ar ... tegrations

How would it be possible to add support for this in domoticz?
Bob123bob
Posts: 31
Joined: Monday 09 March 2015 7:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Add support for sensibo?

Post by Bob123bob »

+1

I have a script at the moment and some virtual switches (4 by pod) I will share it soon.

Other question : it there a way to have one virtual switch for air conditioner with on-off / mode / fan / temperature as one virtual switch ?
olskar
Posts: 17
Joined: Sunday 12 February 2017 15:58
Target OS: -
Domoticz version:
Contact:

Re: Add support for sensibo?

Post by olskar »

Bob123bob wrote:+1

I have a script at the moment and some virtual switches (4 by pod) I will share it soon.

Other question : it there a way to have one virtual switch for air conditioner with on-off / mode / fan / temperature as one virtual switch ?
Nice, looking forward!
Bob123bob
Posts: 31
Joined: Monday 09 March 2015 7:35
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Add support for sensibo?

Post by Bob123bob »

Here are my scripts (sorry for the delay)

One in LUA to manage devices changes in domoticz and one in Python to send command using Sensible API

You will have to create 4 dummy switches by pod
AC STATE switch ON/OFF
AC MODE selectable HEAT/COOL/FAN/AUTO
AC FAN selectable LOW/MEDIUM/HIGH/AUTO
AC TEMPERATURE Temperature

sensibo_client_by_pod.py
I put it in scripts/sensibo folder
make it executable :

Code: Select all

chmod +x sensibo_client_by_pod.py
No changes needed, if you want to test it just execute it using the following command

Code: Select all

python sensibo_client_by_pod.py yourapikey yourpoduid youracstate youracmode youracfan youractemperature 
acstate is on,off ; acmode cool,heat,fan,auto ; acfan low,medium,high,auto ; actemp in a integer in degrees

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 _post(self, path, data, ** params):
        params['apiKey'] = self._api_key
        response = requests.post(_SERVER + path, params = params, data = data)
        response.raise_for_status()
        return response.json()

    def pod_uids(self):
        result = self._get("/users/me/pods")
        pod_uids = [x['id'] for x in result['result']]
        return pod_uids

    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]

    def pod_change_ac_state(self, podUid, on, target_temperature, mode, fan_level):
        self._post("/pods/%s/acStates" % podUid,
                json.dumps({'acState': {"on": on, "targetTemperature": target_temperature, "mode": mode, "fanLevel": fan_level}}))

if __name__ == "__main__":
    import argparse
    parser = argparse.ArgumentParser(description='Sensibo client example parser')
    parser.add_argument('apikey', type = str)
    parser.add_argument('poduid', type = str)
    parser.add_argument('--on', action="store_true", default=False, dest='status')
    parser.add_argument('--off', action="store_false", default=False, dest='status')
    parser.add_argument('temperature', type = int)
    parser.add_argument('mode', type = str)
    parser.add_argument('fan', type = str)
    args = parser.parse_args()

    client = SensiboClientAPI(args.apikey)
    pod_uids = client.pod_uids()
    #print "All pod uids:", ", ".join(pod_uids)
    #print "Pod measurement for first pod", client.pod_measurement(pod_uids[0])
    #last_ac_state = client.pod_ac_state(pod_uids[0])
    #print "Last AC change %(success)s and was caused by %(cause)s" % { 'success': 'was successful' if last_ac_state['status'] == 'Success' else 'failed', 'cause': last_ac_state['reason'] } 
    #print "and set the ac to %s" % str(last_ac_state['acState'])

    client.pod_change_ac_state(args.poduid,args.status,args.temperature,args.mode,args.fan)
    print "Pod UID : ", args.poduid
    print "Status : ", args.status
    print "Temp : ", args.temperature
    print "Mode : ", args.mode
    print "Fan : ", args.fan
    

and second script
script_device_sensibo.lua
I put it in scripts/lua folder
You will have to change device names and edit your sensibo api key and pod iud

Code: Select all

-- script name : script_device_sensibo.lua
-- This script will trigger a python script every time a Sensibo settings using Domoticz dummy switchs change status
-- Create virtual selectable switch. e.g. : "AC State (ON/OFF), Mode (HEAT/COOL/FAN/AUTO), Fan (LOW/MEDIUM/HIGH/AUTO), Temperature"

commandArray = {}

apikey = 'yourapikey'
poduid_bedroom = 'yourpoduid'
poduid_kitchen = 'yourpoduid'


for key, value in pairs(devicechanged) do

  if (key == 'AC Kitchen' or key == 'Mode Kitchen' or key == 'Fan Kitchen' or key == 'Temp Kitchen') then
    poduid = poduid_Kitchen
    state = otherdevices['AC Kitchen']:lower()
    mode = otherdevices['Mode Kitchen']
    fan = otherdevices['Fan Kitchen']
    temperature = math.floor(otherdevices_svalues['Temp Kitchen'])

    if ((devicechanged['AC Kitchen'] == 'On') or (key == 'AC Kitchen') or (otherdevices['AC Kitchen'] == 'On')) then
      os.execute("python /home/pi/domoticz/scripts/sensibo/sensibo_client_by_pod.py "..apikey.." "..poduid.." --"..state.." "..temperature.." "..mode.." "..fan)
      --print("python /home/pi/domoticz/scripts/sensibo/sensibo_client_by_pod.py "..apikey.." "..poduid.." --"..state.." "..temperature.." "..mode.." "..fan)
      --print("API key : "..apikey..", Pod UID : " ..poduid.. ", State : "..state..", Mode : "..mode..", Fan : "..fan..", Temp : "..temperature)
      print("AC Kitchen : "..state..", "..temperature..", "..mode..", "..fan)
    end
  end

  if (key == 'AC Bedroom' or key == 'Mode Bedroom' or key == 'Fan Bedroom' or key == 'Temp Bedroom') then
    poduid = poduid_Bedroom
    state = otherdevices['AC Bedroom']:lower()
    mode = otherdevices['Mode Bedroom']
    fan = otherdevices['Fan Bedroom']
    temperature = math.floor(otherdevices_svalues['Temp Bedroom'])

    if ((devicechanged['AC Bedroom'] == 'On') or (key == 'AC Bedroom') or (otherdevices['AC Bedroom'] == 'On')) then
      os.execute("python /home/pi/domoticz/scripts/sensibo/sensibo_client_by_pod.py "..apikey.." "..poduid.." --"..state.." "..temperature.." "..mode.." "..fan)
      --print("python /home/pi/domoticz/scripts/sensibo/sensibo_client_by_pod.py "..apikey.." "..poduid.." --"..state.." "..temperature.." "..mode.." "..fan)
      --print("API key : "..apikey..", Pod UID : " ..poduid.. ", State : "..state..", Mode : "..mode..", Fan : "..fan..", Temp : "..temperature)
      print("AC Bedroom : "..state..", "..temperature..", "..mode..", "..fan)
    end
  end

end

return commandArray
Hope this code helps people here
I'm not a coder so if you want to improve the scripts you're welcome
Dynodix
Posts: 2
Joined: Monday 01 July 2019 21:45
Target OS: Linux
Domoticz version:
Contact:

Re: Add support for sensibo?

Post by Dynodix »

If someone is interested here is my plugin for Sensibo integration:

https://github.com/dynodix/sensibo
zanckos
Posts: 3
Joined: Sunday 02 February 2020 16:02
Target OS: -
Domoticz version:
Contact:

Re: Add support for sensibo?

Post by zanckos »

Hello,
so here I am new to the rasberry community and how to say ... I am a beautiful quiche :)

I launched into the Raspberry / domoticz et sensibo project (with dynodix's pluggin).

I had already installed Domoticz on a synology and therefore I had no problem doing it on the raspberry.
By cons I followed a tutorial to install the Sensibo plugin.
The plugin installs well but then I have errors in the logs

here they are :2020-02-02 14:52:55.227 Error: (CLim) 'onStart' failed 'AttributeError':''NoneType' object has no attribute 'supported_modes''.
2020-02-02 14:52:55.227 Error: (CLim) ----> Line 189 in '/home/pi/domoticz/plugins/sensibo/plugin.py'
2020-02-02 14:52:55.227 Error: (CLim) ----> Line 44 in '/home/pi/domoticz/plugins/sensibo/plugin.py'
2020-02-02 14:53:04.927 Error: (CLim) 'onHeartbeat' failed 'AttributeError':''NoneType' object has no attribute 'room_temp''.
2020-02-02 14:53:04.927 Error: (CLim) ----> Line 217 in '/home/pi/domoticz/plugins/sensibo/plugin.py'
2020-02-02 14:53:04.927 Error: (CLim) ----> Line 139 in '/home/pi/domoticz/plugins/sensibo/plugin.py'
2020-02-02 14:53:04.927 Error: (CLim) ----> Line 149 in '/home/pi/domoticz/plugins/sensibo/plugin.py'


What to do with it?
Thank you for your help and your patience :)
zanckos
Posts: 3
Joined: Sunday 02 February 2020 16:02
Target OS: -
Domoticz version:
Contact:

Re: Add support for sensibo?

Post by zanckos »

Please nobody ??
zanckos
Posts: 3
Joined: Sunday 02 February 2020 16:02
Target OS: -
Domoticz version:
Contact:

Re: Add support for sensibo?

Post by zanckos »

Please nobody ??
Dynodix
Posts: 2
Joined: Monday 01 July 2019 21:45
Target OS: Linux
Domoticz version:
Contact:

Re: Add support for sensibo?

Post by Dynodix »

Are you able to control your device trough sensibo web? https://home.sensibo.com/login?

Sometimes I got similar errors on one of the 2 devices, but after change some available parameter the device sincronized and everything worked.

At most you should be able to torn on or off the clima with the plugin.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests