Gigaset Elements Cli - domoticz support

In this subforum you can show projects you have made, or you are busy with. Please create your own topic.

Moderator: leecollings

Post Reply
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

I have started to add Domoticz support to my (python based) Gigaset Elements cli which can be found on PyPI and GitHub.

https://github.com/dynasticorpheus/gigasetelements-cli


Image

[FUNCTIONALITY]

Code: Select all

Gigaset Elements - Command-line Interface by [email protected]

optional arguments:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        fully qualified name of configuration-file
  -u USERNAME, --username USERNAME
                        username (email) in use with my.gigaset-elements.com
  -p PASSWORD, --password PASSWORD
                        password in use with my.gigaset-elements.com
  -n TOKEN, --notify TOKEN
                        pushbullet token
  -e EVENTS, --events EVENTS
                        show last <number> of events
  -d DD/MM/YYYY DD/MM/YYYY, --date DD/MM/YYYY DD/MM/YYYY
                        filter events on begin date - end date
  -o HH:MM, --cronjob HH:MM
                        schedule cron job at HH:MM (requires -m option)
  -x, --remove          remove all cron jobs linked to this program
  -f {door,window,motion,siren,plug,button,homecoming,intrusion,systemhealth,camera,phone,smoke}, --filter {door,window,motion,siren,plug,button,homecoming,intrusion,systemhealth,camera,phone,smoke}
                        filter events on type
  -m {home,away,custom}, --modus {home,away,custom}
                        set modus
  -k DELAY, --delay DELAY
                        set alarm timer delay in seconds (use 0 to disable)
  -D, --daemon          daemonize during monitor/domoticz mode
  -z, --notifications   show notification status
  -l LOG, --log LOG     fully qualified name of log file
  -R, --rules           show custom rules
  -P PID, --pid PID     fully qualified name of pid file
  -s, --sensor          show sensor status (use -ss to include sensor id's)
  -b {arm,disarm}, --siren {arm,disarm}
                        arm/disarm siren
  -g {on,off}, --plug {on,off}
                        switch plug on/off
  -a, --camera          show camera status
  -r, --record          switch camera recording on/off
  -A, --snapshot        download camera snapshot
  -t, --monitor         show events using monitor mode (use -tt to activate
                        domoticz mode)
  -i, --ignore          ignore configuration-file at predefined locations
  -N, --noupdate        do not periodically check for updates
  -j, --restart         automatically restart program in case of a connection
                        error
  -q, --quiet           do not send pushbullet message
  -I, --insecure        disable SSL/TLS certificate verification
  -S, --silent          suppress urllib3 warnings
  -v, --version         show version

[TO-DO]
* Set system and sensor status at initial startup
* More sanity checks
* Tell me ...

[INSTALLATION]
In case you want to test please follow below steps:

1. Go to Setup / Hardware in Domoticz GUI
2. Add hardware - dummy
3. Create a virtual sensor - type Alert for basestation (remember the idx number)
4. Create a virtual sensor - type Manual Light/Switch for each motion/door/window/siren/plug/button/camera (remember their idx numbers)
5. Set Off Delay to 2 seconds for virtual sensors linked to motion, button or camera

6. Install gigasetelements-cli using PyPI or GitHub

PyPI

Code: Select all

pip install gigasetelements-cli
GitHub

Code: Select all

git clone git://github.com/dynasticorpheus/gigasetelements-cli.git
cd gigasetelements-cli
python setup.py install --force
7. Download config file and add username and password

Code: Select all

curl -o ~/.gigasetelements-cli/gigasetelements-cli.conf https://raw.githubusercontent.com/dynasticorpheus/gigasetelements-cli/master/gigasetelements-cli.conf.template
Config file will be automatically loaded if found in one of the below locations. Use --config to specify an alternative location.

Code: Select all

/opt/etc/gigasetelements-cli.conf
/usr/local/etc/gigasetelements-cli.conf
/usr/etc/gigasetelements-cli.conf
/etc/gigasetelements-cli.conf
~/.gigasetelements-cli/gigasetelements-cli.conf
~/Library/Application Support/gigasetelements-cli/gigasetelements-cli.conf
8. Run below command to get sensor ids and match them with the their respective idx in domoticz

Code: Select all

gigasetelements-cli -ss
9. Run below command to get camera sensor id. Use the 12 uppercase digits in stream url. This MAC address can also be found on the back of
the camera.

Code: Select all

gigasetelements-cli -a
10. Fill out collected details in the [domoticz] section in the config file.
11. Do a test run of the of the program to see if everything is working as expected.

Code: Select all

gigasetelements-cli -tt
Image
12. Once working start with additional arguments so it runs as daemon, automatically restarts in case of errors and creates a log file.

Code: Select all

gigasetelements-cli -tt --restart --daemon --log /tmp/gigasetelements-cli.log
In case you can't get it running please feel free to post your issue in this thread.

[CUSTOM ICONS]
I extracted the icons used in the adroid app and created a custom set for domoticz.
gse_icons_v4.zip
Gigaset Elements Custom Icons v4
(23.08 KiB) Downloaded 207 times
[BUGS]
https://github.com/dynasticorpheus/giga ... cli/issues

[SUGGESTIONS]
Idea's & suggestions are more than welcome so please let me know. If you like it please star this project on github:
https://github.com/dynasticorpheus/gigasetelements-cli

[UPDATE]
Added base to custom icon set and update domoticz screenshot - 12/02/16
Updated install instruction - 08/05/16
Updated custom icon set to avoid conflicting names - 23/05/16
Update url's - 31/05/16
Added smoke to custom icon set - 01/06/16


Cheers
Dynasticorpheus
Last edited by dynasticorpheus on Wednesday 19 October 2016 17:56, edited 21 times in total.
Stager
Posts: 2
Joined: Monday 12 October 2015 20:41
Target OS: NAS (Synology & others)
Domoticz version:
Location: Amersfoort, NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Stager »

First of all a big thanks for working on gigaset elements support for domoticz! I was really excited trying this out.

I had a couple of start-up problems, mostly caused by not reading carefully. After proper configuration the virtual device gets a status and the variable is updated without any problems.

Things i bumped into:
  1. idx of variable not readable through UI, had to use http://172.20.1.10:8080/json.htm?type=c ... rvariables
  2. couple of (uncaught) crashes due to wrong variable idx
  3. config in ~/gigasetelement-cli/gigasetelements-cli.conf doesn't work anymore
  4. pbtoken can't be removed from config (empty is ok)
I'll trigger some alarms tomorrow. Do you think you can add the motion sensors for example as alert sensor? I have two sensors currently active and it would be great to wire them to turn on the lights. It would be great to have an array for mapping the friendly gigaset device name (or id) and domoticz idx. ID's are visible at https://api.gigaset-elements.com/api/v1/me/basestations
Dlanor
Posts: 67
Joined: Sunday 22 March 2015 16:18
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Dlanor »

Perfect! Keep up the Good work!
Domoticz| Zigbee | SONOFF
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

Stager wrote:
  1. idx of variable not readable through UI, had to use http://172.20.1.10:8080/json.htm?type=c ... rvariables
  2. couple of (uncaught) crashes due to wrong variable idx
  3. config in ~/gigasetelement-cli/gigasetelements-cli.conf doesn't work anymore
  4. pbtoken can't be removed from config (empty is ok)
1. If you go to more options/user variables in the webinterface the idx is shown as first colum
2. Once we have the structure sorted I will add some exception handling
3. I have changed the above instructions to use ~/gigasetelement-cli/gigasetelements-cli.conf as this is the preferred location and is used if more copies are found
4. Again this needs more exception handling however already the case in the main version

I will start working on having a virtual device per gigaset elements sensor, motion and door first.
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

I have pushed an update to github and adjusted the instructions in the OP. Please use the new gigasetelements-cli.conf.template as it contains new/changed values.

This version will push health, motion and door data to separate virtual sensors. (so you need to add two extra ones)

Again current code is really prototype style so there is almost no error handling yet and the code really lacks cleanup/optimization still :!:
Stager
Posts: 2
Joined: Monday 12 October 2015 20:41
Target OS: NAS (Synology & others)
Domoticz version:
Location: Amersfoort, NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Stager »

Changes are working for me :-) I created a new docker image with newer domoticz. Variable IDs are now visible in UI.
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

Stager wrote:Changes are working for me :-) I created a new docker image with newer domoticz. Variable IDs are now visible in UI.
cool, so are you now able to use the motion sensor to switch on the lights? Assuming this can be achieved through a Lua script using data from otherdevices_svalues['Gigaset Elements Motion'] table?

This Lua stuff is new for me so please share if you manage to get this working so I can learn as well :geek:
Dlanor
Posts: 67
Joined: Sunday 22 March 2015 16:18
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Dlanor »

dynasticorpheus wrote: 6. fill out details under [accounts] and [domoticz] section in ~/.gigasetelements-cli/gigasetelements-cli.conf
7. start program in source directory - ./gigasetelements-cli.py -g and let it run in the background (use -gg when triggered by cronjob)
When it runs i get the following error:

Code: Select all

[-] HTTP error 400
Domoticz| Zigbee | SONOFF
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

Really getting hooked to this Domoticz stuff :) I now got it to send me a webcam snapshot via telegram if motion is detected on my gigaset elements camera :ugeek:
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

Dlanor wrote:
dynasticorpheus wrote: 6. fill out details under [accounts] and [domoticz] section in ~/.gigasetelements-cli/gigasetelements-cli.conf
7. start program in source directory - ./gigasetelements-cli.py -g and let it run in the background (use -gg when triggered by cronjob)
When it runs i get the following error:

Code: Select all

[-] HTTP error 400
What options do you use to start the program and can you show me your ~/.gigasetelements-cli/gigasetelements-cli.conf ?

The domoticz part of the program needs at least below values to be filled (domoticz username/password can be empty if they are not setup in domoticz itself)

Code: Select all


[accounts]
# username (email) in use with my.gigaset-elements.com
username: [email protected]

# password in use with my.gigaset-elements.com
password: mybigsecret

# add token to enable pushbullet notification (optional)
pbtoken:


[domoticz]
# domoticz server ip address (optional)
ip: 127.0.0.1

# domoticz server port (optional)
port: 8080

# domoticz user name (optional)
username:

# domoticz password (optional)
password:

# domoticz (alert) device idx numbers (optional)
health: 1
motion: 2
door: 3

# domoticz (string) variable idx number (optional)
variable: 1
andgla
Posts: 1
Joined: Tuesday 21 October 2014 11:28
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by andgla »

Hi
Sounds very promising.
I have a Gigaset kit at home that I was on the way to recycle. I have know changed my mind :)

Do You have any example of how it looks like in Domoticz GUI?

/Anders
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

andgla wrote:Hi
Sounds very promising.
I have a Gigaset kit at home that I was on the way to recycle. I have know changed my mind :)

Do You have any example of how it looks like in Domoticz GUI?

/Anders
As promised ... btw just received my Gigaset Elements Plug so I am playing with that as well now :) Will update the main code soon to add support for this piece of hardware.

Image
Derik
Posts: 1602
Joined: Friday 18 October 2013 23:33
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Arnhem/Nijmegen Nederland
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Derik »

Great Job....
Xu4: Beta Extreme antenna RFXcomE,WU Fi Ping ip P1 Gen5 PVOutput Harmony HUE SolarmanPv OTG Winddelen Alive ESP Buienradar MySensors WOL Winddelen counting RPi: Beta SMAspot RFlinkTest Domoticz ...Different backups
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

I have added domoticz support to the master branch and removed my initial code. This is a completely different approach so please follow updated instructions in OP. In case of questions please let me know.
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

andgla wrote:Hi
Sounds very promising.
I have a Gigaset kit at home that I was on the way to recycle. I have know changed my mind :)

Do You have any example of how it looks like in Domoticz GUI?

/Anders
Did you already have a go at it? Curious to know if it also works well for other people.
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

Latest github version now also supports daemon mode including log file.
Dlanor
Posts: 67
Joined: Sunday 22 March 2015 16:18
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Dlanor »

dynasticorpheus wrote:Latest github version now also supports daemon mode including log file.
Well done! It works perfectly. Any way how to start it with domotics after reboot?
Domoticz| Zigbee | SONOFF
micbou
Posts: 86
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by micbou »

When running the -ss command I get an error saying:
[-] Configuration | ERROR | Username and/or password missing
I'm 100% sure my username and password are in the .conf file and that they are correct. Any advice?
micbou
Posts: 86
Joined: Sunday 01 May 2016 0:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by micbou »

Opgelost door de gigasetelements-cli.conf ergens anders te plaatsen, maar krijg nu:
[-] Configuration | LOADED | /etc/gigasetelements-cli.conf
Traceback (most recent call last):
File "/usr/local/bin/gigasetelements-cli", line 9, in <module>
load_entry_point('gigasetelements-cli==1.4.0', 'console_scripts', 'gigasetelements-cli')()
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 678, in main
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 295, in connect
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 273, in restpost
TypeError: __str__ returned non-string (type Error)
dynasticorpheus
Posts: 115
Joined: Monday 12 October 2015 15:26
Target OS: Linux
Domoticz version: 2.3295
Location: NL
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by dynasticorpheus »

micbou wrote:Opgelost door de gigasetelements-cli.conf ergens anders te plaatsen, maar krijg nu:
[-] Configuration | LOADED | /etc/gigasetelements-cli.conf
Traceback (most recent call last):
File "/usr/local/bin/gigasetelements-cli", line 9, in <module>
load_entry_point('gigasetelements-cli==1.4.0', 'console_scripts', 'gigasetelements-cli')()
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 678, in main
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 295, in connect
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 273, in restpost
TypeError: __str__ returned non-string (type Error)
Er treed een onbekende connectie error op echter door een bug in de oudere versies van urllib3 welke wordt meegeleverd bij requests komt de bijbehorende error message niet naar voren. Stap 1 is dus om requests te updaten zodat we wellicht meer hints krijgen om het een en ander werkend te krijgen.

Code: Select all

pip install --upgrade requests
Verder raad ik aan om in afwachting van de 1.5 release de develop versie te installeren, heb hier en daar wat verbeteringen doorgebracht om het een en ander wat minder foutgevoelig te maken.

Code: Select all

pip install --upgrade https://github.com/dynasticorpheus/gigasetelements-cli/zipball/develop
Hoor van je ...
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest