Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.
As a complete NOOB to Domoticz (started two weeks ago) and pyton scripts could you elaborate in how to process a json call into a script?
My main intention in enabling and disabling timers is that I would like to create a "holidays" button that will activate and deactivate a set of timers that will turn lamps on and off in the house. Next to that I would also like to check the sunrise and sunset times to decide if the outdoor lamps should be turned on or not. Blockly appeared to be ideal for this, but unfortunately I cannot get it to work for me. Next to that the timer functions that can be associated to the buttons are very easy to use and versatile enough except for the problems described above.
Any help on calling the json commands in a python script is very welcome. After that I think I will be able to get it to work for me no problem.
As a complete NOOB to Domoticz (started two weeks ago) and pyton scripts could you elaborate in how to process a json call into a script?
My main intention in enabling and disabling timers is that I would like to create a "holidays" button that will activate and deactivate a set of timers that will turn lamps on and off in the house. Next to that I would also like to check the sunrise and sunset times to decide if the outdoor lamps should be turned on or not. Blockly appeared to be ideal for this, but unfortunately I cannot get it to work for me. Next to that the timer functions that can be associated to the buttons are very easy to use and versatile enough except for the problems described above.
Any help on calling the json commands in a python script is very welcome. After that I think I will be able to get it to work for me no problem.
Thanks for the help.
Other possibilty is to activate the Holiday timer. This option can be found at Setup-Settings-Other-Timer Plan. When Holiday timer is actived, you can set other timers then in the default plan.
Ended up creating a single script that would check a specific group is on or off.
Then depending on the state it enables or disables a set of timers by the id's.
#!/usr/bin/python
import urllib2
import base64
import json
"""
General scrypt settings.
Set the appropriate username and password.
Enter the id of the group that will turn on and off the timers
Enter the ids of the timers that will be turned on and off
"""
domoticzserver = "127.0.0.1:8080"
domoticzusername = "username"
domoticzpassword = "password"
group_id = "1"
timer_ids = [1, 2]
"""
Build the encoded password string
"""
base64string = base64.encodestring('%s:%s' % (domoticzusername, domoticzpassword)).replace('\n', '')
"""
Process the url request
"""
def DomoticzRequest (url):
request = urllib2.Request(url)
request.add_header("Authorization", "Basic %s" % base64string)
response = urllib2.urlopen(request)
return response.read()
"""
Request the group and scene list.
Filter out the status of the desired group id
set the json command based on the status
"""
url = "http://" + domoticzserver + "/json.htm?type=scenes"
data = json.loads(DomoticzRequest(url))
group_info = [obj for obj in data["result"] if(obj["idx"]== group_id)]
group_status = group_info[0]["Status"]
if group_status == "Off":
json_command = "/json.htm?type=command¶m=disabletimer&idx="
else:
json_command = "/json.htm?type=command¶m=enabletimer&idx="
"""
Send the json command for all desired timer ids
"""
for id in timer_ids:
url = "http://" + domoticzserver + json_command + "%i" %id
DomoticzRequest(url)