Page 30 of 47 FirstFirst ... 20252627282930313233343540 ... LastLast
Results 291 to 300 of 470

Thread: Decoded - EvoHome API access to control remotely.

  1. #291
    Automated Home Jr Member
    Join Date
    Jun 2016
    Posts
    24

    Default

    Quote Originally Posted by DBMandrake View Post
    Are you sure you're seeing more granular info on that one zone ? The existing domoticz script polls the V2 API which still only gives 0.5 degree resolution, so I don't really see how that one zone could have additional resolution.

    Is that from looking at the exact temperatures on the temperature dashboard or are you judging by graphs ? The graphs will have interpolation which may make it appear there is more detail than there really is.

    I'll see if I get a chance to try adapting the script tonight or maybe tomorrow.
    My mistake ... I was checking the Domoticz mobile app and the temperature had fluctuated over time in that room - it was showing 0.5 resolution.

  2. #292
    Automated Home Legend
    Join Date
    Sep 2014
    Location
    Scotland
    Posts
    2,204

    Default

    Ok I got it to work. You can find the modified version of the script here:

    Code:
    #!/usr/bin/python
    #
    # Copyright 2015 - fullTalgoRythm
    # 
    # Licensed under GNU General Public License 3.0 or later. 
    # Some rights reserved. See COPYING, AUTHORS.
    # 
    # @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+>
    #
    # see http://www.domoticz.com/wiki/Evohome
    # see http://evohome-client.readthedocs.org/en/latest/index.html
    #
    
    import evoconfig
    from evohomeclient2 import EvohomeClient
    import evohomeclient
    import requests
    import json
    import datetime
    import base64
    import os
    import sys, traceback
    
    if os.path.isfile("/var/tmp/evo-noup.tmp"):
    	os.remove("/var/tmp/evo-noup.tmp")
    	sys.exit(1)
    	
    #connect to evohome web portal @ http://www.mytotalconnect.com
    client = EvohomeClient(evoconfig.usr,evoconfig.pw)
    #also connect to V1 API to fetch more accurate temperature readings
    client1 = evohomeclient.EvohomeClient(evoconfig.usr,evoconfig.pw)
    fi=client.full_installation()
    systemId=fi['gateways'][0]['temperatureControlSystems'][0]['systemId']
    modelType=fi['gateways'][0]['temperatureControlSystems'][0]['modelType']
    status=client.locations[0].status()
    tcs=status['gateways'][0]['temperatureControlSystems'][0]
    zones=tcs['zones']
    currentmode=tcs['systemModeStatus']['mode']
    
    createdev=False
    updatedev=True
    
    hwname="evohome"
    if len(sys.argv)>1:
    	mode=sys.argv[1]
    	if mode=="init":
    		createdev=True
    		if len(sys.argv)>2:
    			hwname=sys.argv[2]
    	elif mode=="quick":
    		updatedev=False
    
    if createdev:
    	#create evohome script hardware
    	r=requests.get("http://%s:%s/json.htm?type=command&param=addhardware&htype=40&port=1&name=%s&enabled=true&datatimeout=0" % (evoconfig.url,evoconfig.port,hwname))
    
    #find last added evohome script hw
    r=requests.get("http://%s:%s/json.htm?type=hardware" % (evoconfig.url,evoconfig.port))
    hwl=json.loads(r.text)
    hwid=-1
    for hw in hwl['result']:
    	if hw['Type']==40:
    		hwid=int(hw['idx'])
    if hwid==-1:
    	print "ERROR: evohome hardware not found"
    	sys.exit(1)
    
    if createdev:
    	#create evohome controller device
    	r=requests.get("http://%s:%s/json.htm?type=createevohomesensor&idx=%d&sensortype=69" % (evoconfig.url,evoconfig.port,hwid))
    	#create evohome dhw device
    	r=requests.get("http://%s:%s/json.htm?type=createevohomesensor&idx=%d&sensortype=71" % (evoconfig.url,evoconfig.port,hwid))
    	#create evohome zones - create all 12 as helpful if they are sequential
    	for i in range(12):
    		r=requests.get("http://%s:%s/json.htm?type=createevohomesensor&idx=%d&sensortype=70" % (evoconfig.url,evoconfig.port,hwid))
    
    #update evohome devices with default name, id for portal access and correct location/name of script to run
    r=requests.get("http://%s:%s/json.htm?type=devices&displayhidden=1&used=all" % (evoconfig.url,evoconfig.port))
    devl=json.loads(r.text)
    for dev in devl['result']:
    	if dev['HardwareID']==hwid:
    		if dev['SubType']=='Evohome':
    			if updatedev:
    				r=requests.get("http://%s:%s/json.htm?type=setused&idx=%s&deviceid=%s&used=true&name=%s&strparam1=%s" % (evoconfig.url,evoconfig.port,dev['idx'],systemId,modelType,base64.urlsafe_b64encode('%s/evo-setmode.sh {status}' % (evoconfig.srt))))
    			r=requests.get("http://%s:%s/json.htm?type=command&param=switchmodal&idx=%s&status=%s&action=0&ooc=1" % (evoconfig.url,evoconfig.port,dev['idx'],currentmode))
    		elif dev['SubType']=='Hot Water' and 'dhw' in tcs:
    			dhw=tcs['dhw']
    			if updatedev:
    				r=requests.get("http://%s:%s/json.htm?type=setused&idx=%s&deviceid=%s&used=true&name=%s&strparam1=%s" % (evoconfig.url,evoconfig.port,dev['idx'],dhw['dhwId'],"Hot Water",base64.urlsafe_b64encode('%s/evo-setdhw.sh {deviceid} {mode} {state} {until}' % (evoconfig.srt))))
    			zonemode=dhw['stateStatus']['mode']
    			if currentmode=="HeatingOff" or currentmode=="AutoWithEco" or currentmode=="Custom":# dhw has no economy mode and does not turn off for heating off also appears custom does not support the dhw zone
    				currentmode="Auto"
    			if zonemode=="FollowSchedule":
    				zonemode=currentmode
    			req="http://%s:%s/json.htm?type=command&param=udevice&idx=%s&nvalue=0&svalue=%s;%s;%s" % (evoconfig.url,evoconfig.port,dev['idx'],dhw['temperatureStatus']['temperature'],dhw['stateStatus']['state'],zonemode)
    			if zonemode=="TemporaryOverride":
    				req+=";%s" % (dhw['stateStatus']['until'])
                    	r=requests.get(req)
    		elif dev['SubType']=='Zone' and dev['Unit']<=len(zones):
    			zone=zones[dev['Unit']-1]
    			if updatedev:
    				r=requests.get("http://%s:%s/json.htm?type=setused&idx=%s&deviceid=%s&used=true&name=%s&strparam1=%s" % (evoconfig.url,evoconfig.port,dev['idx'],zone['zoneId'],zone['name'],base64.urlsafe_b64encode('%s/evo-settemp.sh {deviceid} {mode} {setpoint} {until}' % (evoconfig.srt))))
    		        if not zone['temperatureStatus']['isAvailable']:
                    		continue
    		        zonemode=zone['heatSetpointStatus']['setpointMode']
    		        #for custom mode the rooms are assignable so ideally we need to check the schedule and see if the room is assigned or not
    		        if zonemode=="FollowSchedule" or currentmode=="HeatingOff": #heating off doesn't support override i.e. heating is permanently switched off
    		                zonemode=currentmode
    			# Extract the measured temperature from the V1 API for increased accuracy. Match zones between API's via id/zoneId.
    			for zonetemp in client1.temperatures():
    				if int(zonetemp['id'])==int(zone['zoneId']):
    					break
    			req="http://%s:%s/json.htm?type=command&param=udevice&idx=%s&nvalue=0&svalue=%s;%s;%s" % (evoconfig.url,evoconfig.port,dev['idx'],zonetemp['temp'],zone['heatSetpointStatus']['targetTemperature'],zonemode)
    		        if zonemode=="TemporaryOverride":
    		               req+=";%s" % (zone['heatSetpointStatus']['until'])
                    	r=requests.get(req)
    
    if createdev:
    	print "Your evohome zones should now be available in the Domoticz"
    Back up evo-update.sh and replace it with this. Remember to make it executable.

    Here it is as a diff to make it more obvious what I changed:

    Code:
    --- evo-update.bak	2016-08-04 20:46:45.063303828 +0100
    +++ evo-update.sh	2016-08-04 22:46:30.607098161 +0100
    @@ -13,6 +13,7 @@
     
     import evoconfig
     from evohomeclient2 import EvohomeClient
    +import evohomeclient
     import requests
     import json
     import datetime
    @@ -26,6 +27,8 @@
     	
     #connect to evohome web portal @ http://www.mytotalconnect.com
     client = EvohomeClient(evoconfig.usr,evoconfig.pw)
    +#also connect to V1 API to fetch more accurate temperature readings
    +client1 = evohomeclient.EvohomeClient(evoconfig.usr,evoconfig.pw)
     fi=client.full_installation()
     systemId=fi['gateways'][0]['temperatureControlSystems'][0]['systemId']
     modelType=fi['gateways'][0]['temperatureControlSystems'][0]['modelType']
    @@ -103,7 +106,11 @@
     		        #for custom mode the rooms are assignable so ideally we need to check the schedule and see if the room is assigned or not
     		        if zonemode=="FollowSchedule" or currentmode=="HeatingOff": #heating off doesn't support override i.e. heating is permanently switched off
     		                zonemode=currentmode
    -			req="http://%s:%s/json.htm?type=command&param=udevice&idx=%s&nvalue=0&svalue=%s;%s;%s" % (evoconfig.url,evoconfig.port,dev['idx'],zone['temperatureStatus']['temperature'],zone['heatSetpointStatus']['targetTemperature'],zonemode)
    +			# Extract the measured temperature from the V1 API for increased accuracy. Match zones between API's via id/zoneId.
    +			for zonetemp in client1.temperatures():
    +				if int(zonetemp['id'])==int(zone['zoneId']):
    +					break
    +			req="http://%s:%s/json.htm?type=command&param=udevice&idx=%s&nvalue=0&svalue=%s;%s;%s" % (evoconfig.url,evoconfig.port,dev['idx'],zonetemp['temp'],zone['heatSetpointStatus']['targetTemperature'],zonemode)
     		        if zonemode=="TemporaryOverride":
     		               req+=";%s" % (zone['heatSetpointStatus']['until'])
                     	r=requests.get(req)
    Full disclaimer - this is a really quick hack just to see if it can be done. There is no proper error checking in case anything goes wrong, and it requires a successful connection to both V1 and V2 API servers (which I believe are completely separate servers) for the script to succeed. If either server doesn't respond that polling period will be missed. (Fortunately the V1 API servers seem to be very reliable so probably not an issue in practice)

    The way I did it is open a connection to the V1 API as well, all data except for the measured zone temperatures is still retrieved from the V2 API, then to find the measured temperature from the V1 API, for each V2 zone I iterate the list of returned V1 zones looking for a match between the V1 'id' and V2 'zoneId' fields. When a match is found the 'temp' figure is retrieved and substituted in place of the V2 temperature reading.

    Seems to work for me, and I now have two decimal places on my domoticz temperature dashboard...

    By the way I've also confirmed from my munin graphs that this new more accurate V1 temperature data does indeed have no setpoint biasing - the difference is clearly obvious in the graphs due to the way I overlay set points and measured temperatures on the same graph - previously every time there was a large set point change from below to above the current temperature (or vica versa) you would nearly always see an immediate 0.5 degree change in the measured temperature at the same time the set point changed, even though the room can't have possibly changed temperature so quickly. (This is the set point biasing)

    No such effect now - when a zone is scheduled to come on all I see is the valid, delayed, gradual rise in temperature, no immediate 0.5 degree "rise".
    Last edited by DBMandrake; 13th August 2016 at 12:47 PM.

  3. #293
    Automated Home Jr Member
    Join Date
    Nov 2014
    Location
    UK
    Posts
    31

    Default

    Hi,
    Now with some data in, you can see the rather coarse steps on the left of the graphs contrasted with the rather smoother parts of the graphs on the right.
    I am seeing ~0.06C increments now.
    Hope this was of interest?

    Would love to get clearer information about Revision 1 and Revision 2 mentioned as the key I have only seems to allow me to access revision 1
    evohome01.jpg
    evohome02.jpg

  4. #294
    Automated Home Jr Member
    Join Date
    Jun 2016
    Posts
    24

    Default

    Quote Originally Posted by DBMandrake View Post
    Ok I got it to work. You can find the modified version of the script here:

    http://paste.debian.net/786969/

    Back up evo-update.sh and replace it with this. Remember to make it executable, and it might be better to use the download link rather than copying and pasting from the text link into an editor.

    (Edit: and here it is as a diff to make it more obvious what I changed: http://paste.debian.net/786972/ )
    Could you reshare your updated script please as the links above are dead ?
    Thanks

  5. #295
    Automated Home Legend
    Join Date
    Sep 2014
    Location
    Scotland
    Posts
    2,204

    Default

    Quote Originally Posted by victorp1612 View Post
    Could you reshare your updated script please as the links above are dead ?
    Thanks
    Sorry - I didn't realise the Debian paste bin expires pages. I've updated the original post to embed the script in the message in code tags. It is still working nicely for me by the way.

  6. #296
    Automated Home Jr Member
    Join Date
    Jun 2016
    Posts
    24

    Default

    Thanks , works like a charm :-)

  7. #297
    Automated Home Lurker
    Join Date
    Aug 2016
    Posts
    4

    Default

    I assume there is still no way to log if there is demand for heat? I think I may have spotted a bug. The valves are reading around 21c due to the hot weather. The summer setpoint is 16C. if eco mode is enabled the boiler will fire up. As there is a 8C difference i wouldn't expect the boiler to fire up. if eco mode is off the boiler doesn't appear to fire up.

  8. #298
    Automated Home Legend
    Join Date
    Sep 2014
    Location
    Scotland
    Posts
    2,204

    Default

    Quote Originally Posted by dp11 View Post
    I assume there is still no way to log if there is demand for heat? I think I may have spotted a bug. The valves are reading around 21c due to the hot weather. The summer setpoint is 16C. if eco mode is enabled the boiler will fire up. As there is a 8C difference i wouldn't expect the boiler to fire up. if eco mode is off the boiler doesn't appear to fire up.
    Most likely one of the set points on an HR92 has not updated correctly and is out of sync with the controller.

    Don't just take what the Evotouch controller says for granted if you have phantom boiler activation - you need to go around every single HR92 and manually check what it's reported set point actually is. I can almost guarantee that there will be a discrepancy where the set point shown on the Evotouch says 16 but the HR92 itself says something higher, thus explaining the boiler activation.

    It is possible (if communication messages between controller and HR92 are lost) for the controller to report a low set point on the screen, and yet the system will call for heat from the boiler. The messages from an HR92 that call for heat (relayed via the controller) are completely separate to the indicated measured temperature and set points. This is a "heat demand" figure which is not displayed to the user, nor provided by the server API and is only available via an HGI80.

    BTW there is also a bug in Eco mode (which I've reported before in the wishlist thread) both in documentation and operation. Eco mode is documented to reduce "all" set points by 3 degrees according to on screen help and PDF documentation, however in actual fact it won't reduce any zone which is already at or below 15 degrees. In my opinion this is by design and it is the documentation which is in error.

    In addition to this discrepancy between documented operation and actual functioning, there also seems to be a bug - rather than all zones above 15 degrees being reduced by 3 degrees then being "clipped" at 15 degrees, instead, if the zone temperature minus 3 degrees would fall below 15 degrees the temperature is not reduced at all.

    Thus what actually happens is any zone at or below 17.5 degrees stays at the temperature it was at, yet zones at or above 18 degrees will be reduced by 3 degrees.

    So you get the weird situation where a zone set to 17 degrees remains at 17 in eco mode but one that is at 18 degrees drops to 15! Clearly a bug that was missed during testing...

    One other thought - although I haven't proven it, I suspect that the bi-weekly "cycle" that HR92's which would otherwise always be closed (due to low set points) do to help prevent valves sticking may actually send a boiler demand and thus bring the boiler on for a short time.

    On a couple of occasions in the summer I have noticed the boiler come on when I'm not expecting it to based on measured temperatures and set points, I've literally run around the house checking the set points of all HR92's manually, not found any that should be causing heat demand, but by the time I've been around the house the boiler has gone back off and remains off for the rest of the day - I believe this could be an HR92 doing it's bi-weekly valve cycling.

    In both cases the boiler only came on once and only remained on for less than a minute, judging by my 3 minute pump overrun which had just finished by the time I had been around the house checking.
    Last edited by DBMandrake; 29th August 2016 at 12:05 AM.

  9. #299
    Automated Home Lurker
    Join Date
    Aug 2016
    Posts
    4

    Default

    Thanks for that. Time to add a relay controlled by a raspberry pi so the heating is only allowed to come on if it is colder than the set points.

  10. #300
    Automated Home Legend
    Join Date
    Sep 2014
    Location
    Scotland
    Posts
    2,204

    Default

    Quote Originally Posted by dp11 View Post
    Thanks for that. Time to add a relay controlled by a raspberry pi so the heating is only allowed to come on if it is colder than the set points.
    I don't think that's a good idea.

    The idea that heating should only come on if the temperature is below the set point and go off if it is equal or even slightly above is false - in all but the warmest weather it takes a constant input of heat to maintain the set point. Doing what you suggest would cause the temperature to oscillate up and down which is exactly what the evohome system strives to avoid.

    Better to locate the real cause of the problem.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •