Eneco Toon Homeseer Script/Plugin

Forum over Homeseer Plugin ontwikkelingen, hierin staan aparte forums voor bijvoorbeeld Plugwise, RFXcom, Fritzbox, Alphatronics etc.

Moderator: Digit

bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Eneco Toon Homeseer Script/Plugin

Post by bartbakels »

Dear all,

Just to let you know, I am currently working on a homeseer 3 script to interface the eneco toon thermostat. Untill now im able to login, start, get current states and logout. As soon as I will get all functions working I will post the script on here. Maybe someone can build a plugin from it.

Keep in mind its nothing fancy and im not a scripting specialist ;)

and special thanks to RVDM from https://github.com/rvdm/toon

Regards

Bart
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Eneco Toon Homeseer Script/Plugin v0.1

Post by bartbakels »

dear all,

hereby version v0.1 of the script. For now it can only be used to write a setpoint and change modes. It also displays some current values of the toon in the homeseer log. In the next version these values will be pushed to 1 or more homeseer devices. In addition all other values such as current E/gas usage/costs etc will be made accesible by this script.

The reason I post this pre beta now;

I''ve tested the current script with HS3 and HS2 (v0.1). When I going to push values to homeseer devices it would not be compatible with HS2 anymore.
Im not a scripting guru, so I know I did something a bit clumsy, so please correct me ;)

Installation instructions:

save the code as toon.vb and create an homeseer event with parameters described in the header, except when using HS2 use these parameters ("Main","USERNAME,PASSWORD,SETPOINT,MODE")
The username and password are the same as for your eneco access

So here it is, and please comment and feel free to give me some feedback :D

v0.1 usable for HS2 and HS3

Code: Select all

Sub Main(params as object)

'Control Eneco Toon Thermostat From Homeseer v0.1
'Made by Bart Bakels/ Promedes.nl
'Usage Script parameters; USERNAME,PASSWORD,SETPOINT,MODE
' No setpoint change fill in nothing; USERNAME,PASSWORD,,MODE
' no mode change fill in nothing USERNAME,PASSWORD,SETPOINT,
' only status update  fill in USERNAME,PASSWORD,,
' modestates; 0=comfort; 1=thuis 2=slapen 3=weg

'Enable Debug Messages Level
'0=None
'1=Info
'2=All

Dim Debug = 1

'=====================================================================

'Get parameters
Dim parameters(4) as String
parameters = params.Split(",")

Dim Username As String = parameters(0) 
Dim Password As String = parameters(1) 
Dim setpoint As String = parameters(2)
Dim selectedmode As String = parameters(3)



'random needs to be a valid UUID1
Dim Random = "12344178-1544-5648-1234-567882545632"

dim indexstart
dim indexend

Dim loginresponse
Dim startresponse
Dim logoutresponse
Dim stateresponse
Dim spsetresponse
Dim modesetresponse

Dim clientid
Dim clientidchecksum
Dim agreementid
Dim agreementidchecksum




'======================
'Login
'======================

loginresponse = hs.URLAction("https://toonopafstand.eneco.nl/toonMobileBackendWeb/client/login?username=" & Username & "&password=" & Password,"GET", "", "")

If Debug = 2 Then 
hs.WriteLog("Toon response login Pri", loginresponse)
End If

'======================
'find IDS
'======================

indexstart = InStr(loginresponse, """clientId"":")
indexstart = indexstart + 13
clientid = Mid(loginresponse,indexstart , 36 )

If Debug = 2 Then 
hs.WriteLog("toon ClientID", clientid)
End If

indexstart = InStr(loginresponse, """clientIdChecksum"":")
indexstart = indexstart + 21
clientidchecksum = Mid(loginresponse,indexstart , 40 )

If Debug = 2 Then 
hs.WriteLog("toon ClientIDChecksum", clientidchecksum)
End If

indexstart = InStr(loginresponse, """agreementId"":")
indexstart = indexstart + 16
agreementid = Mid(loginresponse,indexstart , 5 )

If Debug = 2 Then 
hs.WriteLog("toon AgreementID", agreementid)
End If

indexstart = InStr(loginresponse, """agreementIdChecksum"":")
indexstart = indexstart + 24
agreementidchecksum = Mid(loginresponse,indexstart , 40 )

If Debug = 2 Then 
hs.WriteLog("toon AgreementIDChecksum", agreementidchecksum)
End If

'======================
'Start 
'======================

startresponse = hs.URLAction("https://toonopafstand.eneco.nl/toonMobileBackendWeb/client/auth/start?clientId=" & clientid & "&clientIdChecksum=" & clientidchecksum & "&agreementId=" & agreementid & "&agreementIdChecksum=" & agreementidchecksum & "&random=" & random,"GET", "", "")

If Debug = 2 Then
hs.WriteLog("Toon response Start", startresponse)
End If	



'======================
'Retrieve Toon State
'======================

stateresponse = hs.URLAction("https://toonopafstand.eneco.nl/toonMobileBackendWeb/client/auth/retrieveToonState?clientId=" & clientid & "&clientIdChecksum=" & clientidchecksum & "&random=" & random,"GET", "", "")

If Debug = 2 Then 
hs.WriteLog("Toon response status", stateresponse)
End If



'======================
'Write Manual Setpoint to Toon
'======================
Dim setpointraw

If NOT setpoint = "" Then

setpointraw = setpoint*100

spsetresponse = hs.URLAction("https://toonopafstand.eneco.nl/toonMobileBackendWeb/client/auth/setPoint?clientId=" & clientid & "&clientIdChecksum=" & clientidchecksum & "&value=" & setpointraw & "&random=" & random,"GET", "", "")

If Debug = 1 Then 
hs.WriteLog("Toon SP written","SP set to: " & setpoint & "  response: " & spsetresponse)
End If


End If


'======================
'Write Mode to Toon
'======================



If NOT selectedMode = "" Then


modesetresponse = hs.URLAction("https://toonopafstand.eneco.nl/toonMobileBackendWeb/client/auth/schemeState?clientId=" & clientid & "&clientIdChecksum=" & clientidchecksum & "&state=2&temperatureState=" & selectedMode & "&random=" & random,"GET", "", "")

If Debug = 1 Then 
hs.WriteLog("Toon Mode written","Mode set to: " & selectedMode & "  response: " & modesetresponse)
End If


End If

'======================
'Logout 
'======================

logoutresponse = hs.URLAction("https://toonopafstand.eneco.nl/toonMobileBackendWeb/client/auth/logout?clientId=" & clientid & "&clientIdChecksum=" & clientidchecksum & "&random=" & random,"GET", "", "")

If Debug = 2 Then 
hs.WriteLog("Toon response logout", logoutresponse)
End If

'======================
'decode state
'======================

Dim currenttemp
Dim currentsetpoint
Dim burnerstatus
Dim currentmode As String

indexstart = InStr(stateresponse, """currentTemp"":")
indexstart = indexstart + 14
currenttemp = Mid(stateresponse,indexstart , 5 )
currenttemp = currenttemp/100

If Debug > 0 Then 
hs.WriteLog("Toon CurrentTemp", currenttemp)
End If



indexstart = InStr(stateresponse, """currentSetpoint"":")
indexstart = indexstart + 18
currentsetpoint = Mid(stateresponse,indexstart , 5 )
currentsetpoint = currentSetpoint/100

If Debug > 0 Then 
hs.WriteLog("Toon CurrentSP", currentsetpoint)
End If



indexstart = InStr(stateresponse, """burnerInfo"":")
indexstart = indexstart + 15
burnerstatus = Mid(stateresponse,indexstart , 1 )


If Debug > 0 Then 
hs.WriteLog("Toon burnerStatus", burnerstatus)
End If




indexstart = InStr(stateresponse, """activeState"":")
indexstart = indexstart + 14
currentmode = Mid(stateresponse,indexstart , 2 )

if currentmode = " -" 
currentmode = "Manueel"
End if
if currentmode = " 0" 
currentmode = "comfort"
End if
if currentmode = " 1" 
currentmode = "thuis"
End if
if currentmode = " 2" 
currentmode = "slapen"
End if
if currentmode = " 3" 
currentmode = "weg"
End if

If Debug > 0 Then 
hs.WriteLog("Toon currentmode", currentmode)
End If



If Debug > 0 Then 
hs.WriteLog("Toon", "Success")
End If


End Sub
Last edited by bartbakels on Wed Feb 12, 2014 10:29 am, edited 1 time in total.
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Re: Eneco Toon Homeseer Script/Plugin

Post by bartbakels »

Hi all,

In the next version the login credentials will be stored in a ini. As well as the automatic generated device references. Im planning to create devices for each value in HS3 such as;

-PV
-SP
-Mode
- Burnerstate
-Curent Gas usage
-current E usage
-Current Gas costs
-Current E costs
-Total gas usage
-Total E Usage
- etc

In addition it would be helpfull to have a VB JSON interpreter. But could not found a usable solution, any suggestions?

regards

Bart
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Re: Eneco Toon Homeseer Script/Plugin

Post by bartbakels »

Dear all,

IM getting there. The script now creats and updates the toon devices automatic, and the credentials are now stored in a INI. In addition I posted a screenshot. keep u posted
Screenshot
Screenshot
screenshot.png (123.46 KiB) Viewed 34407 times
Regards

Bart
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Eneco Toon Homeseer Script/Plugin v0.4 available

Post by bartbakels »

Dear all,

hereby version 0.4,

dropbox.com/s/vay4t6tdmsul77s/ToonHS3sc ... ipt0_4.zip

- Just Unzip the content of the zip to your Homeseer 3 root
- Change the login credentials in the toonscript.ini file in the config directory.
- Create an event which will call the script every X minutes for status updates. parameters; ,

To change mode use an additional event with the parameters; ,MODE
To change setpoint use an additional event with the parameters; SETPOINT,

when the event is run for the first time the following devices are created;
screenshot devices
screenshot devices
screenshot.png (291.22 KiB) Viewed 34388 times
:D

I plan to create buttons to change modes, but this is not yet supported in HS3 for my understanding.

Please feel free to comment, give feature request or what so ever.

regards

Bart
Last edited by bartbakels on Thu Feb 13, 2014 7:33 pm, edited 1 time in total.
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
Edwin
Member
Member
Posts: 447
Joined: Sat Oct 20, 2007 6:37 am
Location: Netherlands

Re: Eneco Toon Homeseer Script/Plugin

Post by Edwin »

looking great,
verry good job

greetings edwin
User avatar
esschenk
Member
Member
Posts: 426
Joined: Sun Feb 17, 2008 10:34 pm
Location: Netherlands
Contact:

Re: Eneco Toon Homeseer Script/Plugin

Post by esschenk »

Good Job

Ed
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Re: Eneco Toon Homeseer Script/Plugin

Post by bartbakels »

Dear All,

I am working on some improvements;

- an status device including last update, status, etc
- errorhandeling
- better data parsing
- calculate dayusage and costs?
- buttons to control the thermostat (as son as supported by HS3)

Are there any other feature request?

regards

Bart
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
User avatar
RdP
Advanced Member
Advanced Member
Posts: 989
Joined: Thu May 04, 2006 10:14 am
Location: Netherlands

Re: Eneco Toon Homeseer Script/Plugin

Post by RdP »

Hi Bart,

Nice job !!!!

I can put the Thermostat part in my IPThermostat plug-in, if you share your scripts with me. I want to keep the IPThermostat plug-in solely for Thermostats and keep things simple.

On the other hand it's a bit stupid to have only the thermostat part of the Toon in my Plug-in.

I can offer you to create a Toon plug-in based on what you already have done and than you'll have the needed buttons as well :-)

The problem is that I don't have a Toon and it will cost me a fair amour of time to create a plug-in, although it gets easier with every new plug-in.

Let me know your thoughts?

/Rien
Rien
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Re: Eneco Toon Homeseer Script/Plugin

Post by bartbakels »

Rien,

Thanks for your response. I think your correct that the toon has some more usefull functions which can/ need to be used.

So a dedicated plugin would be the best way to go in my opinion. The script is not password protected so be my guest. In addition if u go for the option to built a plugin, i would love to help. So i can learn something ;) im still waiting on a visonic plugin ( maybe reverse engineering) and mayby a conversion of my hue script to a plugin for hs3.

If u have any questions please contact me here or pb me.

Regards

Bart
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Eneco Toon Homeseer Script/Plugin release 1.0

Post by bartbakels »

dear all,

hereby version 1.0 of the HS3 toon script.

dropbox.com/s/azmwt7f38qfag0k/ToonHS3sc ... ipt1_0.zip

changes;

-errorhandeling
-buttons for mode change
-buttons for sp change
-info/status device
-day gas and electra usage

Be advised, the Control (script) buttons do not work in HSTOUCH, probably a bug, which has been communicated with the HS team

please comment, if there are issues and or feature requests.

regards

Bart
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Eneco Toon Homeseer Script/Plugin v1.1

Post by bartbakels »

dear all,

version 1.1 dropbox.com/s/yvzzsfueoytf3ji/toon%20v1 ... 20v1_1.zip

hereby version 1.1, changed the daily E usage. I projected the low usage only as total usage which offcource is not correct. Now there are 3 devices wich represent;

E Day (laagtarief) usage
E Day (hoogtarief) usage
E Day Total usage

IMPORTANT, I also changed the script parameter call to a "|" divider instead of ",", so please check your script calls. Please remove all old devices and run the script again, the devices will be created again.

If there are any additional questions please comment.

regards

Bart
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
smaling
Starting Member
Starting Member
Posts: 1
Joined: Mon Mar 24, 2014 5:35 pm

Re: Eneco Toon Homeseer Script/Plugin

Post by smaling »

Hello,

How 2 install this?
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Re: Eneco Toon Homeseer Script/Plugin

Post by bartbakels »

Just follow the instructions in the header and in this topic.

Btw as soon as the new hs3 update is released i will release the new version with working hstouch buttons.

Regards
Bart
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
bartbakels
Advanced Member
Advanced Member
Posts: 515
Joined: Tue May 31, 2011 6:44 pm
Contact:

Re: Eneco Toon Homeseer Script/Plugin

Post by bartbakels »

dear all,

I have a new version available which fixes some small bugs and the buttons are working in HStouch now. However this only works with the beta release of homeseer. Any interest in this version?

regards

Bart
Software: HS3, HStouch, Plugwise , BLBackup, BLLatestImage, Zwave, JowiHUE, PHlocation, Netcam, Harmony Plugin, ThinkingCleaner, HSPhone, Eneco Toon Script, Pushover, Visonic Powermax LV Interface

(ON ESXI )on NUC
Post Reply

Return to “Homeseer Plugins Forum”