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

Kwintessens
Posts: 25
Joined: Monday 10 October 2016 13:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Kwintessens »

dynasticorpheus wrote:
Kwintessens wrote:
Wherever I can help let me know. :) Care to share your script? I think firing it off from a button press instead of scheduled job would definitely work for me as a workaround. :D
Sorry what script do you mean? The script I have running checks every minute the state of the system (Home/Away/Custom) and puts the selector switch in the same postition. This is the one you also want?
Yes, I cannot seem to receive the state using any command and see no changes in the logs either.. If I'm able to get the status (and write that status away in the switch) I can integrate it with the rest of my automation in Domoticz.
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 »

Kwintessens wrote:
dynasticorpheus wrote:
Kwintessens wrote:
Wherever I can help let me know. :) Care to share your script? I think firing it off from a button press instead of scheduled job would definitely work for me as a workaround. :D
Sorry what script do you mean? The script I have running checks every minute the state of the system (Home/Away/Custom) and puts the selector switch in the same postition. This is the one you also want?
Yes, I cannot seem to receive the state using any command and see no changes in the logs either.. If I'm able to get the status (and write that status away in the switch) I can integrate it with the rest of my automation in Domoticz.

Sorry took a while to find some time. You need to adjust the config part ofcourse. This script assumes no password is required to access domoticz. If needed you can whitelist the local IP address or any other ip (range) this avoid auth. (settings --> Local Networks (no username/password)

The scripts sets a cookie in the temp dir specified so it only needs to authenticate with the gigaset elements servers every 6 hours. This makes the script quicker and prevents hammering their servers :)

Make sure it works by changing the alarm modus via de gigaset elements website and running the script manually. Once this is the case you can schedule a cron job which runs every minute. There is also a LUA script somewhere here on this forum which allows you to schedule jobs every 1,5 etc minute. I personally use that one because than the script only runs when domoticz is up and running.

Of course this needs to be added to the cli when running in domoticz mode but lacking time at the moment but it's def on my to-do list 8-)

Code: Select all

#!/bin/sh -e

##########################CONFIG#############################################
[email protected]
PWD=mybigsecret
IP=127.0.0.1
PORT=8080
IDX=112
TMPDIR=/tmp
##########################CONFIG#############################################

##########################URL################################################
URL_ID=https://im.gigaset-elements.de/identity/api/v1/user/login
URL_AUTH=https://api.gigaset-elements.de/api/v1/auth/openid/begin?op=gigaset
URL_BASE=https://api.gigaset-elements.de/api/v1/me/basestations
##########################URL################################################

echo
echo Gigaset Elements Modus Curl-Cli version 0.1
echo

MODUS="unset"
LEVEL="$(curl -s "http://$IP:$PORT/json.htm?type=devices&rid=$IDX" | jq '.result[0].Level' | tr -d "'")"

if test `find "$TMPDIR/gse_expire" -mmin +355`; then
  echo cookies older than 6 hours so deleting
  rm -f $TMPDIR/gse_cookies
fi

if [ ! -f $TMPDIR/gse_cookies ]; then
  echo [-] authenticating
  touch $TMPDIR/gse_expire
  curl -siSL --user-agent 'Mozilla/5.0' --insecure --cacert $TMPDIR/gse_expire --cookie $TMPDIR/gse_cookies --cookie-jar $TMPDIR/gse_cookies --data email=$EMAIL --data password=$PWD $URL_ID
  curl -siSL --user-agent 'Mozilla/5.0' --insecure --cacert $TMPDIR/gse_expire --cookie $TMPDIR/gse_cookies --cookie-jar $TMPDIR/gse_cookies -H "Accept: application/json" -H "Content-Type: application/json" -X GET $URL_AUTH
else
  echo "[-] pre-authenticated"
fi

MODUS="$(curl --insecure --cacert $TMPDIR/gse_expire -siSL --tlsv1 --ipv4 --user-agent 'Mozilla/5.0' --cookie $TMPDIR/gse_cookies --cookie-jar $TMPDIR/gse_cookies -H "Content-Type: application/json" -X GET $URL_BASE | sed -e 's/[{}]/''/g' |   awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | grep active_mode | cut -d '"' -f6)"
echo "[-] current modus $MODUS"
echo "[-] current level $LEVEL"

if [ "$MODUS" = "home" -a $LEVEL != "0" ]; then
   ADJLEVEL=0

elif [ "$MODUS" = "custom" -a $LEVEL != "10" ]; then
   ADJLEVEL=10

elif [ "$MODUS" = "away" -a $LEVEL != "20" ]; then
   ADJLEVEL=20

else
   echo "[-] update of selector switch not needed"
   echo
   exit;
fi

echo "[-] settting selector switch to $MODUS (level $ADJLEVEL)"
curl -s "http://$IP:$PORT/json.htm?type=command&param=udevice&idx=$IDX&nvalue=1&svalue=$ADJLEVEL"
curl -s "http://$IP:$PORT/json.htm?type=command&param=addlogmessage&message=(Gigaset%20Elements)%20$MODUS%20Modus%20Detected%20(Gigaset%20Elements)"
echo
exit;
Attachments
gse_syncmodus.zip
(1.07 KiB) Downloaded 101 times
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 »

Kwintessens wrote:
dynasticorpheus wrote:
Kwintessens wrote:
Thanks you so much :D.

Everything's running smoothly for the past couple of weeks. Now I am trying to automate a little bit more and thinking of ideas how to do so.

I want to control more scripts and lighting on the basis of my home or away state. It doesn't seem to be possible to monitor mode from an event in the CLI.

I am currently setting my away mode from gigaset button on double press, and home mode from single press. The problem with this is that double-presses are not recognized as such (logs all show single press).

I don't think I should need an additional gigaset button to set alarm in addition to my current button.. so am I missing some logic here? :mrgreen:
Thanks for the feedback!

As workaround I currently have a curl script running every minute which updates the base selector switch to the current state should however be implemented in the CLI itself of course :geek: Don't have too much time at the moment but I will put in on my to-do list.

We should probably also use a selector switch for button so we can differentiate between the actual press. From there we can assign an action to the respective level. Again I will put it on my to-do list.

Code: Select all

00 Off
10 Short       -------> gigasetelements-cli --modus home
20 Long
30 Longer
40 Double      -------> gigasetelements-cli --modus away
Wherever I can help let me know. :) Care to share your script? I think firing it off from a button press instead of scheduled job would definitely work for me as a workaround. :D

Work in progress ... actually not to much code to change to make this work ... will test a bit more tonight

Image
Kwintessens
Posts: 25
Joined: Monday 10 October 2016 13:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Kwintessens »

dynasticorpheus wrote:
Kwintessens wrote:
dynasticorpheus wrote:
Thanks for the feedback!

As workaround I currently have a curl script running every minute which updates the base selector switch to the current state should however be implemented in the CLI itself of course :geek: Don't have too much time at the moment but I will put in on my to-do list.

We should probably also use a selector switch for button so we can differentiate between the actual press. From there we can assign an action to the respective level. Again I will put it on my to-do list.

Code: Select all

00 Off
10 Short       -------> gigasetelements-cli --modus home
20 Long
30 Longer
40 Double      -------> gigasetelements-cli --modus away
Wherever I can help let me know. :) Care to share your script? I think firing it off from a button press instead of scheduled job would definitely work for me as a workaround. :D

Work in progress ... actually not to much code to change to make this work ... will test a bit more tonight

Image
Great!!

I am running the script after button push (to avoid cronjob) as this is my single source of status change, but not ideal because it doesn't distinguish between types of push, so that update is welcome!

The coming days I will tie my plugs, lights and robotic vacuum to my away mode :).
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 »

Kwintessens wrote:
dynasticorpheus wrote:
Kwintessens wrote:
Wherever I can help let me know. :) Care to share your script? I think firing it off from a button press instead of scheduled job would definitely work for me as a workaround. :D

Work in progress ... actually not to much code to change to make this work ... will test a bit more tonight

Image
Great!!

I am running the script after button push (to avoid cronjob) as this is my single source of status change, but not ideal because it doesn't distinguish between types of push, so that update is welcome!

The coming days I will tie my plugs, lights and robotic vacuum to my away mode :).
Is the bash/curl script I shared earlier working for you? (will be the next thing I am going to add to the cli so in the end we don't need it anymore)
Kwintessens
Posts: 25
Joined: Monday 10 October 2016 13:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Kwintessens »

dynasticorpheus wrote:
Kwintessens wrote:
dynasticorpheus wrote:

Work in progress ... actually not to much code to change to make this work ... will test a bit more tonight

Image
Great!!

I am running the script after button push (to avoid cronjob) as this is my single source of status change, but not ideal because it doesn't distinguish between types of push, so that update is welcome!

The coming days I will tie my plugs, lights and robotic vacuum to my away mode :).
Is the bash/curl script I shared earlier working for you? (will be the next thing I am going to add to the cli so in the end we don't need it anymore)
Yes, it's working fine.. I just edited the states to positions 10, 20 and 30 as 0 state is off to me.
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 »

Kwintessens wrote:
dynasticorpheus wrote:
Kwintessens wrote:
Great!!

I am running the script after button push (to avoid cronjob) as this is my single source of status change, but not ideal because it doesn't distinguish between types of push, so that update is welcome!

The coming days I will tie my plugs, lights and robotic vacuum to my away mode :).
Is the bash/curl script I shared earlier working for you? (will be the next thing I am going to add to the cli so in the end we don't need it anymore)
Yes, it's working fine.. I just edited the states to positions 10, 20 and 30 as 0 state is off to me.
You can test the button selector switch by installing below branch and update the config file so button is linked to the newly created selector switch:

Code: Select all

git clone -b 14-button https://github.com/dynasticorpheus/gigasetelements-cli.git
cd gigasetelements-cli
pip install -r requirements.txt
python setup.py install --force
Let me know if it also works ok for you
Kwintessens
Posts: 25
Joined: Monday 10 October 2016 13:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Kwintessens »

dynasticorpheus wrote:
Kwintessens wrote:
dynasticorpheus wrote:
Is the bash/curl script I shared earlier working for you? (will be the next thing I am going to add to the cli so in the end we don't need it anymore)
Yes, it's working fine.. I just edited the states to positions 10, 20 and 30 as 0 state is off to me.
You can test the button selector switch by installing below branch and update the config file so button is linked to the newly created selector switch:

Code: Select all

git clone -b 14-button https://github.com/dynasticorpheus/gigasetelements-cli.git
cd gigasetelements-cli
pip install -r requirements.txt
python setup.py install --force
Let me know if it also works ok for you
Encountering the following error:
/etc$ gigasetelements-cli -ss
Traceback (most recent call last):
File "/bin/gigasetelements-cli", line 11, in <module>
load_entry_point('gigasetelements-cli==1.5.0b2', 'console_scripts', 'gigasetelements-cli')()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 564, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2621, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2281, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2287, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 20, in <module>
File "/usr/lib/python2.7/site-packages/pushbullet/__init__.py", line 2, in <module>
from .pushbullet import Pushbullet
File "/usr/lib/python2.7/site-packages/pushbullet/pushbullet.py", line 8, in <module>
from .filetype import get_file_type
File "/usr/lib/python2.7/site-packages/pushbullet/filetype.py", line 12, in <module>
import magic
File "/usr/lib/python2.7/site-packages/magic.py", line 150, in <module>
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') or ctypes.util.find_library('cygmagic-1')
File "/usr/lib/python2.7/ctypes/util.py", line 242, in find_library
raise RuntimeError("can not find library %s" % name)
RuntimeError: can not find library magic
I think it has to do something with a missing dependency? I think I've encountered this before but I don't remember how I solved it.
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 »

Kwintessens wrote:
dynasticorpheus wrote:
Kwintessens wrote: Yes, it's working fine.. I just edited the states to positions 10, 20 and 30 as 0 state is off to me.
You can test the button selector switch by installing below branch and update the config file so button is linked to the newly created selector switch:

Code: Select all

git clone -b 14-button https://github.com/dynasticorpheus/gigasetelements-cli.git
cd gigasetelements-cli
pip install -r requirements.txt
python setup.py install --force
Let me know if it also works ok for you
Encountering the following error:
/etc$ gigasetelements-cli -ss
Traceback (most recent call last):
File "/bin/gigasetelements-cli", line 11, in <module>
load_entry_point('gigasetelements-cli==1.5.0b2', 'console_scripts', 'gigasetelements-cli')()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 564, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2621, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2281, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2287, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 20, in <module>
File "/usr/lib/python2.7/site-packages/pushbullet/__init__.py", line 2, in <module>
from .pushbullet import Pushbullet
File "/usr/lib/python2.7/site-packages/pushbullet/pushbullet.py", line 8, in <module>
from .filetype import get_file_type
File "/usr/lib/python2.7/site-packages/pushbullet/filetype.py", line 12, in <module>
import magic
File "/usr/lib/python2.7/site-packages/magic.py", line 150, in <module>
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') or ctypes.util.find_library('cygmagic-1')
File "/usr/lib/python2.7/ctypes/util.py", line 242, in find_library
raise RuntimeError("can not find library %s" % name)
RuntimeError: can not find library magic
I think it has to do something with a missing dependency? I think I've encountered this before but I don't remember how I solved it.
Did you also run?

Code: Select all

pip install -r requirements.txt
I am guessing it's missing python-magic which should be installed when running above command. If this somehow does not work perhaps you can install it with your regular package install tool? What OS are you running?
Kwintessens
Posts: 25
Joined: Monday 10 October 2016 13:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Kwintessens »

dynasticorpheus wrote:
Kwintessens wrote:
dynasticorpheus wrote:
You can test the button selector switch by installing below branch and update the config file so button is linked to the newly created selector switch:

Code: Select all

git clone -b 14-button https://github.com/dynasticorpheus/gigasetelements-cli.git
cd gigasetelements-cli
pip install -r requirements.txt
python setup.py install --force
Let me know if it also works ok for you
Encountering the following error:
/etc$ gigasetelements-cli -ss
Traceback (most recent call last):
File "/bin/gigasetelements-cli", line 11, in <module>
load_entry_point('gigasetelements-cli==1.5.0b2', 'console_scripts', 'gigasetelements-cli')()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 564, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2621, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2281, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2287, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 20, in <module>
File "/usr/lib/python2.7/site-packages/pushbullet/__init__.py", line 2, in <module>
from .pushbullet import Pushbullet
File "/usr/lib/python2.7/site-packages/pushbullet/pushbullet.py", line 8, in <module>
from .filetype import get_file_type
File "/usr/lib/python2.7/site-packages/pushbullet/filetype.py", line 12, in <module>
import magic
File "/usr/lib/python2.7/site-packages/magic.py", line 150, in <module>
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') or ctypes.util.find_library('cygmagic-1')
File "/usr/lib/python2.7/ctypes/util.py", line 242, in find_library
raise RuntimeError("can not find library %s" % name)
RuntimeError: can not find library magic
I think it has to do something with a missing dependency? I think I've encountered this before but I don't remember how I solved it.
Did you also run?

Code: Select all

pip install -r requirements.txt
I am guessing it's missing python-magic which should be installed when running above command. If this somehow does not work perhaps you can install it with your regular package install tool? What OS are you running?
I am running it on a Synology.. and I did install requirements.. it even says that all requirements are satisfied.
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 »

Below will get you back on the master or develop branch whilst we get this sorted.

Code: Select all

git clone -b master https://github.com/dynasticorpheus/gigasetelements-cli.git
cd gigasetelements-cli
pip install -r requirements.txt
python setup.py install --force
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 »

Kwintessens wrote:
dynasticorpheus wrote:
Kwintessens wrote:
Encountering the following error:



I think it has to do something with a missing dependency? I think I've encountered this before but I don't remember how I solved it.
Did you also run?

Code: Select all

pip install -r requirements.txt
I am guessing it's missing python-magic which should be installed when running above command. If this somehow does not work perhaps you can install it with your regular package install tool? What OS are you running?
I am running it on a Synology.. and I did install requirements.. it even says that all requirements are satisfied.
I updated the code to lazy load the pushbullet module meaning that you most likely will not have this error as long as you do not use the --notify option. (or have a pushbullet token in the config file)

Please install the updated code and let me know if this helps for now. You should still try to solve the issue as other programs relying on python-magic will also fail I guess.

Code: Select all

git clone -b 14-button https://github.com/dynasticorpheus/gigasetelements-cli.git
cd gigasetelements-cli
pip install -r requirements.txt
python setup.py install --force
Kwintessens
Posts: 25
Joined: Monday 10 October 2016 13:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Kwintessens »

It works now, but with -ss I still get the following errors, indeed related to pushbullet. Doesn't matter to me since it works just fine.. I've tried to resolve the python-magic before but was unsuccessful (see below).

Have yet to test the button in combination with the home/away modes.. What did you change in this version compared to the previous one? Then I know how to test your new additions to it :).

File "/bin/gigasetelements-cli", line 11, in <module>
load_entry_point('gigasetelements-cli==1.5.0b2', 'console_scripts', 'gigasetelements-cli')()
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 764, in main
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 740, in base
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 444, in pb_message
File "/usr/lib/python2.7/site-packages/pushbullet/__init__.py", line 2, in <module>
from .pushbullet import Pushbullet
File "/usr/lib/python2.7/site-packages/pushbullet/pushbullet.py", line 8, in <module>
from .filetype import get_file_type
File "/usr/lib/python2.7/site-packages/pushbullet/filetype.py", line 12, in <module>
import magic
File "/usr/lib/python2.7/site-packages/magic.py", line 150, in <module>
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') or ctypes.util.find_library('cygmagic-1')
File "/usr/lib/python2.7/ctypes/util.py", line 242, in find_library
raise RuntimeError("can not find library %s" % name)
RuntimeError: can not find library magic
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 »

Kwintessens wrote:It works now, but with -ss I still get the following errors, indeed related to pushbullet. Doesn't matter to me since it works just fine.. I've tried to resolve the python-magic before but was unsuccessful (see below).

Have yet to test the button in combination with the home/away modes.. What did you change in this version compared to the previous one? Then I know how to test your new additions to it :).

File "/bin/gigasetelements-cli", line 11, in <module>
load_entry_point('gigasetelements-cli==1.5.0b2', 'console_scripts', 'gigasetelements-cli')()
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 764, in main
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 740, in base
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 444, in pb_message
File "/usr/lib/python2.7/site-packages/pushbullet/__init__.py", line 2, in <module>
from .pushbullet import Pushbullet
File "/usr/lib/python2.7/site-packages/pushbullet/pushbullet.py", line 8, in <module>
from .filetype import get_file_type
File "/usr/lib/python2.7/site-packages/pushbullet/filetype.py", line 12, in <module>
import magic
File "/usr/lib/python2.7/site-packages/magic.py", line 150, in <module>
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') or ctypes.util.find_library('cygmagic-1')
File "/usr/lib/python2.7/ctypes/util.py", line 242, in find_library
raise RuntimeError("can not find library %s" % name)
RuntimeError: can not find library magic
I have optimized the code so it really does not depend on the pushbullet module unless actually sending a notification. Should already have been like this so thanks for reporting :geek: Please reinstall and let me know if you are now error free.

Button now needs to point to a selector button as it differentiates between the different kind of presses. From there you can attach actions to them using standard Domoticz functionality.

See below for my setup:

Image

Image

and the log entries:

Image
Kwintessens
Posts: 25
Joined: Monday 10 October 2016 13:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Kwintessens »

dynasticorpheus wrote:
Kwintessens wrote:It works now, but with -ss I still get the following errors, indeed related to pushbullet. Doesn't matter to me since it works just fine.. I've tried to resolve the python-magic before but was unsuccessful (see below).

Have yet to test the button in combination with the home/away modes.. What did you change in this version compared to the previous one? Then I know how to test your new additions to it :).

File "/bin/gigasetelements-cli", line 11, in <module>
load_entry_point('gigasetelements-cli==1.5.0b2', 'console_scripts', 'gigasetelements-cli')()
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 764, in main
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 740, in base
File "build/bdist.linux-armv7l/egg/gigasetelements/gigasetelements.py", line 444, in pb_message
File "/usr/lib/python2.7/site-packages/pushbullet/__init__.py", line 2, in <module>
from .pushbullet import Pushbullet
File "/usr/lib/python2.7/site-packages/pushbullet/pushbullet.py", line 8, in <module>
from .filetype import get_file_type
File "/usr/lib/python2.7/site-packages/pushbullet/filetype.py", line 12, in <module>
import magic
File "/usr/lib/python2.7/site-packages/magic.py", line 150, in <module>
dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') or ctypes.util.find_library('cygmagic-1')
File "/usr/lib/python2.7/ctypes/util.py", line 242, in find_library
raise RuntimeError("can not find library %s" % name)
RuntimeError: can not find library magic
I have optimized the code so it really does not depend on the pushbullet module unless actually sending a notification. Should already have been like this so thanks for reporting :geek: Please reinstall and let me know if you are now error free.

Button now needs to point to a selector button as it differentiates between the different kind of presses. From there you can attach actions to them using standard Domoticz functionality.

See below for my setup:

Image

Image

and the log entries:

Image
Great! It works like a charm, and the error is gone now :).

Do you advise an off delay of 2 seconds? It seems to work just fine without delay. I have never understood the 'very long' push, how many seconds is that?

Anyway, I'll start integrating everything now and share later :). Again, great work!
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 »

Kwintessens wrote:
Do you advise an off delay of 2 seconds? It seems to work just fine without delay. I have never understood the 'very long' push, how many seconds is that?

Anyway, I'll start integrating everything now and share later :). Again, great work!
I guess it is required once you start attaching activities to a button press because otherwise is detects the specific press over and over? (in reality you also release the button and it returns to unpressed status) Experiment a bit and use what works best for you I would say

Long press is like 2 seconds and very long like 5 seconds or more ...

Now thinking how to best implement to update the current modus using the selector switch, the actual updating is not the problem but we have now 2 domoticz sensors for base (alert/selector) which I would like to merge into one if possible ...
Kwintessens
Posts: 25
Joined: Monday 10 October 2016 13:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Kwintessens »

dynasticorpheus wrote: Now thinking how to best implement to update the current modus using the selector switch, the actual updating is not the problem but we have now 2 domoticz sensors for base (alert/selector) which I would like to merge into one if possible ...
I understand what you're saying for that is a more elegant way.. From a Gigaset Elements point of view (as seen in the app) these are different.. The base state is more related to status of sensors and intrusion, whereas the other is simply the away state. If you're trying to combine the two I am not sure how you will be able to use it for both showing and setting the state.

Small update on my part:

I wasn't able to have the button trigger the bash script of checking/setting gigaset mode directly.. So I made small lua script that does the same :). It works perfectly now, and I think it is a more elegant way than setting it directly on action. Since the button is my single point of changing state I also think this lua script is better than a timed one :).

The domoticz capabilities were the sole reason I invested in this system so it's awesome that everything is coming together now.. :D
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 »

Kwintessens wrote:
I understand what you're saying for that is a more elegant way.. From a Gigaset Elements point of view (as seen in the app) these are different.. The base state is more related to status of sensors and intrusion, whereas the other is simply the away state. If you're trying to combine the two I am not sure how you will be able to use it for both showing and setting the state.

Small update on my part:

I wasn't able to have the button trigger the bash script of checking/setting gigaset mode directly.. So I made small lua script that does the same :). It works perfectly now, and I think it is a more elegant way than setting it directly on action. Since the button is my single point of changing state I also think this lua script is better than a timed one :).

The domoticz capabilities were the sole reason I invested in this system so it's awesome that everything is coming together now.. :D
Ok next round, I have updated the code and it now syncs the modus selector switch every 60 seconds. Just add the idx to the base sensor in your config file like below example. First the idx of the alert than the selector idx. (I also updated the instructions in gigasetelements-cli.conf.template)

Code: Select all

F32A76C4DHJ1B743A0E0D74EFD2375D1=98,96
Then install below branch for testing ... (dont forget to disable the curl/cron script as we don't need it anymore)

Code: Select all

git clone -b 12-base https://github.com/dynasticorpheus/gigasetelements-cli.git
cd gigasetelements-cli
pip install -r requirements.txt
python setup.py install --force
Let me know
Kwintessens
Posts: 25
Joined: Monday 10 October 2016 13:37
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: Gigaset Elements Cli - domoticz support

Post by Kwintessens »

dynasticorpheus wrote:
Kwintessens wrote:
I understand what you're saying for that is a more elegant way.. From a Gigaset Elements point of view (as seen in the app) these are different.. The base state is more related to status of sensors and intrusion, whereas the other is simply the away state. If you're trying to combine the two I am not sure how you will be able to use it for both showing and setting the state.

Small update on my part:

I wasn't able to have the button trigger the bash script of checking/setting gigaset mode directly.. So I made small lua script that does the same :). It works perfectly now, and I think it is a more elegant way than setting it directly on action. Since the button is my single point of changing state I also think this lua script is better than a timed one :).

The domoticz capabilities were the sole reason I invested in this system so it's awesome that everything is coming together now.. :D
Ok next round, I have updated the code and it now syncs the modus selector switch every 60 seconds. Just add the idx to the base sensor in your config file like below example. First the idx of the alert than the selector idx. (I also updated the instructions in gigasetelements-cli.conf.template)

Code: Select all

F32A76C4DHJ1B743A0E0D74EFD2375D1=98,96
Then install below branch for testing ... (dont forget to disable the curl/cron script as we don't need it anymore)

Code: Select all

git clone -b 12-base https://github.com/dynasticorpheus/gigasetelements-cli.git
cd gigasetelements-cli
pip install -r requirements.txt
python setup.py install --force
Let me know
I'll test ASAP. What is the benefit of syncing it every 60 seconds over having it sync on my button press (which means it only triggers that curl script 2-3 times a day), other than that it will also sync if status is changed from other source? Just wondering, as I might want to limit unnecessary server calls when my girlfriend and me are at work all day.

Few automations I have done so far:
-Lua script on single button tap (come home) that turns on single light IF time is not between sunrise and sunset: Someone comes home in the dark and disarms the alarm (or alarm is disarmed but it is still dark because someone is asleep).

- Lua script on Home mode: Turn on wemo switch for Gigaset Camera when away, turn off when home.

- Lua script on Home mode: Turn off TP-link switch when away (set top box and other random electronics that don't need power when away)/Enable when home.

Future:
- Set schedule to clean up/mop my home with robo vacuum with validation if I'm away.
- Set custom mode for sleeping
- Other cool ideas?
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 »

Kwintessens wrote:
I'll test ASAP. What is the benefit of syncing it every 60 seconds over having it sync on my button press (which means it only triggers that curl script 2-3 times a day), other than that it will also sync if status is changed from other source? Just wondering, as I might want to limit unnecessary server calls when my girlfriend and me are at work all day.

Few automations I have done so far:
-Lua script on single button tap (come home) that turns on single light IF time is not between sunrise and sunset: Someone comes home in the dark and disarms the alarm (or alarm is disarmed but it is still dark because someone is asleep).

- Lua script on Home mode: Turn on wemo switch for Gigaset Camera when away, turn off when home.

- Lua script on Home mode: Turn off TP-link switch when away (set top box and other random electronics that don't need power when away)/Enable when home.

Future:
- Set schedule to clean up/mop my home with robo vacuum with validation if I'm away.
- Set custom mode for sleeping
- Other cool ideas?
Still testing a bit but next version will allow setting the API polling interval for new events and the interval for status/health sync

O and ... send the robo vauum to my house as well please :D
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest