Integrate custom http api for smart home mygekko

Hello,

looking for a solution to integrate mygekko home automation. There doesn’t seem to be native support for HA but there is an http API, it seems to be a resftful API:

Query API (my-gekko.com)

Does anyone have a good approach on how to create entities in HA bases on this API to control things like lights and shutters?
I am trying to make HA work with a personal setup of mygekko (smart home). So my goal is not to develop and publish an integration but to get it working in an individual setup.

Here is an extract of the API when I use it in a browser:

"lights": {

	"item0":	{

		"name":	"room1",

		"page":	"EG",

		"sumstate":	{
"value": "state[0=Off|1=On]; dimValue[%]; RGBcolor[24Bit]; sum[0=Ok|1=ManualOff|2=ManualOn|3=Locked|4=Alarm]",

"type": "STRING",

"permission": "READ",

"index": 100000

		},

		"scmd":	{
"value": "0|1|D100|TOG|C255 (0=Off|1=On|Dim%|Toggle|RGB24Bit)",

"type": "STRING",

"permission": "WRITE",

"index": 100001

		}

	},

	"item1":	{

		"name":	"room2",

		"page":	"EG",

		"sumstate":	{
"value": "state[0=Off|1=On]; dimValue[%]; RGBcolor[24Bit]; sum[0=Ok|1=ManualOff|2=ManualOn|3=Locked|4=Alarm]",

"type": "STRING",

"permission": "READ",

"index": 100100

		},

		"scmd":	{
"value": "0|1|D100|TOG|C255 (0=Off|1=On|Dim%|Toggle|RGB24Bit)",

"type": "STRING",

"permission": "WRITE",

"index": 100101

		}

I can successfully set on a light with:
https://live.my-gekko.com/api/v1/var/lights/item8/scmd/set?value=1&username=shrek&key=xxxxx&gekkoid=yyyyyy

and set it to off accordingly with value=0 in a webbrowser.

I am looking for help getting this integrated into HA and I am missing experience and knowledge how to leverage the existing Rest integrations best for this.

Thank you,
Shrek

Hi,
I got the covers to work with:

sensor:
  - platform: rest
    name: mygekko_rollos
    resource: http://192.168.178.33/api/v1/var/blinds/status
    username: admin
    password: xxxxx
    authentication: basic
    json_attributes:
      - item0
      - item1
      - item2
      - item3
      - item4
      - item5
      - item6
      - item7
      - item8
      - item9
      - item10
      - item11
    value_template: "OK"
    scan_interval: 1
  - platform: rest
    name: mygekko_temps
    resource: http://192.168.178.33/api/v1/var/roomtemps
    username: admin
    password: xxx
    authentication: basic
    json_attributes:
      - item0
      - item1
      - item2
      - item3
      - item4
      - item5
      - item7
      - item8
    value_template: "OK"
    scan_interval: 1
  - platform: template
    sensors:
      test_temperature:
        device_class: temperature
        unit_of_measurement: "°C"
        value_template: >-
         '{{ states.sensor.mygekko_temps.attributes["item7"]["sumstate"]["value"].split(";")[1] }}'

shell_command:
  shutter_up:        "curl 'http://192.168.178.33/api/v1/var/blinds/item{{ device_id }}/scmd/set?value=1&username=admin&password=xxx'"
  shutter_down:      "curl 'http://192.168.178.33/api/v1/var/blinds/item{{ device_id }}/scmd/set?value=-1&username=admin&password=xxx'"
  shutter_stop:      "curl 'http://192.168.178.33/api/v1/var/blinds/item{{ device_id }}/scmd/set?value=0&username=admin&password=xxxxx"
  shutter_position:  "curl 'http://192.168.178.33/api/v1/var/blinds/item{{ device_id }}/scmd/set?value=P{{ position }}&username=admin&password=xxx'"
  change_temp:       "curl 'http://192.168.178.33/api/v1/var/roomtemps/item7/scmd/set?value=K%2$s&username=admin&password=xxxxx'"

cover:
  - platform: template
    covers:
      shutter_treppe_window:
        friendly_name: "Treppenfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item0"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 0
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 0
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 0
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 0
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_treppe_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_hwr_window:
        friendly_name: "HWRfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item1"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 1
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 1
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 1
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 1
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_hwr_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_wc_window:
        friendly_name: "WCfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item2"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 2
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 2
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 2
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 2
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_wc_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_schlafzimmer_window:
        friendly_name: "Schlafzimmerfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item3"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 3
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 3
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 3
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 3
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_schlafzimmer_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_couch_window:
        friendly_name: "Couchfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item4"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 4
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 4
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 4
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 4
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_terrasse_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_terrasse_window:
        friendly_name: "Terrassefenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item5"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 5
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 5
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 5
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 5
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_terrasse_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_kueche_window:
        friendly_name: "Küchenfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item6"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 6
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 6
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 6
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 6
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_kueche_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_malte_window:
        friendly_name: "Maltefenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item7"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 7
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 7
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 7
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 7
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_malte_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_tim_window:
        friendly_name: "Timfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item8"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 8
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 8
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 8
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 8
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_tim_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_spielzimmer_window:
        friendly_name: "Spielzimmerfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item9"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 9
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 9
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 9
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 9
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_spielzimmer_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_buero_window:
        friendly_name: "Bürofenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item10"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 10
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 10
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 10
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 10
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_buero_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}
      shutter_badezimmer_window:
        friendly_name: "Badzimmerfenster"
        device_class: shutter
        position_template: '{{ ((states.sensor.mygekko_rollos.attributes["item11"]["sumstate"]["value"].split(";")[1] | int) *-1 +100) }}'
        open_cover:
          service: shell_command.shutter_up
          data: 
            device_id: 11
        close_cover:
          service: shell_command.shutter_down
          data: 
            device_id: 11
        stop_cover:
          service: shell_command.shutter_stop
          data: 
            device_id: 11
        set_cover_position:
          service: shell_command.shutter_position
          data_template: 
            device_id: 11
            position: "{{ position *-1 +100 }}"
        icon_template: >-
          {% if is_state('cover.shutter_badezimmer_window', 'open') %}
            mdi:blinds-open
          {% else %}
             mdi:blinds
          {% endif %}

I didnt get the temp to work so far. did you get it to work?

here some iobroker phyton. maybe some skilled people can take it and build integration into HA ?

@StephanU ?

Found something

Hi everyone,

yes, I recently started to develop a myGekko integration for HA. The integration will be divided in two parts:

Currently only the “Login” to the Query API is working. I’m planning to have covers working within the next week.
I don’t personally own a MyGekko, I’m doing this for a friend (and for fun :slight_smile:)

1 Like

wow awesome :smiley:
i m here with HA 2023.3.4 and myGekko slide2 ver 6436-12. ready for help on test/log/report…
thank you

Must be a very good friend ;D
Integration of 25 systems coasts me a lot of time. The documentation is poor and the API changed random with breaking changes. For example the vent model is over 400 lines of code to identify the vent system.

EVentType ventTypeEnum(int? state) {
  switch (state) {
    case 0:
      return EVentType.INDIVIDUAL;
    case 1:
      return EVentType.PLUGGIT;
    case 2:
      return EVentType.PROXXON_V1;
    case 3:
      return EVentType.WESTAFLEX;
    case 4:
      return EVentType.STIEBEL_TECALOR;
    case 5:
      return EVentType.PROXXON_V2;
    default:
      return EVentType.INDIVIDUAL;
  }
}

Depends on the system you have to execute different API calls and you need to know which system is supporting which function. Ah, each system model extends a main object with 100 lines of code.

For example the vent is locked you are not able to execute a function means you need a lot of checks and error handling for every system.

Happy coding :smiley:

1 Like

Ok… I was hoping the Query API is “abstracting away” vendor specific details. Well, let’s see how far we can get with this :slight_smile:
Did you also write a Home Assistant integration?

I made the mobile App Gekko Control.

https://forum.my-gekko.com/showthread.php?tid=1830

2 Likes

Help by testing would be great :grinning:
You could actually start right now :slight_smile: by installing the Integration as custom repository in HACS: Custom Repositories | HACS (assuming you do have HACS installed).
After installing the integration you can search for it “the ususal way” via “Settings->Integrations”.
Currently, you need to have a “myGEKKO Plus” service subscription as the integration accesses the query api via “https://live.my-gekko.com/api/v1/var/”, but I will add support to connect to myGekko locally via the ip address.

1 Like

done with HACS,
after setup integration i now have not my blind (18item) but have 10device + 10entity as the item from your api_var_demo_data.json (same name and quantity item0 to item9)

That’s my static test data :upside_down_face: I forgot to switch off the demo mode before relasing the integration. I just made a new release which fixes this (and adds initial support for opening/closing covers). You should see an update when opening the integration in HACS. :slight_smile:

1 Like

i post on private git my full API’s response .
on “var” there is some difference (i m on last mygekko’s firmware)

“sumstate”: {
“value”

to

“sumstate”: {
“description”

i have venetian blind/raffstore that have also tilt angle

edit: may be usefull add a “device remove” as __init__.py ZHA Zigbee Tested Devices...Please add your device results - #319 by Quatuor if an myGekko’s user change a name on device.

thanks for the integration. But I cant get it to work. I got only tle HACs integration to run. I run on my pi 4 the home assistant os. Is there a way how to run your pymygekko on home assistant os? Can you integrate the api into your integration or that you can use it with the local mygekko api?

[quote=“Fummy, post:14, topic:416323, full:true”]Is there a way how to run your pymygekko
[/quote]

you have NOT to run pymygekko.
follw install instruction here GitHub - StephanU/MyGekko: Home Assistant integration for myGekko using the myGekko Query API. so after installed on HACS you only need to configure under “Integrations”. (and restart HA may help sometime :wink: )

have you a “plus” on mygekko? at the moment no local API in this integration (may need to crate user/password and ACTIVATE local api on SLIDE)

@StephanU check this out and leave a message on the thread.

https://forum.my-gekko.com/showthread.php?tid=2289

1 Like

The mygekko client library is released.
https://pinpong.github.io/mygekko-client-library/