Controlling Toon [HACKED] from Domoticz

For heating/cooling related questions in Domoticz

Moderator: leecollings

User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gielie »

I have a strange problem with my Toon P1 script.
The return amount is way too high, about 1.8.10^16.
When i look at the script, it gives nothing, which is right.

Code: Select all

pi@raspberrypi:~/domoticz/scripts/php $ ./p1_meter_data_json.php
Request for FROM date: 03-05-2018
Now: 2018-05-03 15:06:46
Electricity Usage Counter Domoticz = 7941058 Wh
Electricity Production Counter Domoticz = 8110649752 Wh

Electricity Usage Toon = 470 Watt
Electricity Production Toon = 0 Watt
Electricity LT counter from Toon = 4045973 Wh
Electricity NT counter from Toon = 3895103 Wh
Electricity Counter Toon Total = 7941076 Wh
Electricity production counter LT from Toon =  Wh
Electricity production counter NT from Toon =  Wh
Write new value 
{
   "status" : "OK",
   "title" : "Update Device"
the usage is right, how can i solve this
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
FunFair
Posts: 52
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair »

I
gielie wrote: Thursday 03 May 2018 15:10 I have a strange problem with my Toon P1 script.
The return amount is way too high, about 1.8.10^16.
When i look at the script, it gives nothing, which is right.

Code: Select all

pi@raspberrypi:~/domoticz/scripts/php $ ./p1_meter_data_json.php
Request for FROM date: 03-05-2018
Now: 2018-05-03 15:06:46
Electricity Usage Counter Domoticz = 7941058 Wh
Electricity Production Counter Domoticz = 8110649752 Wh

Electricity Usage Toon = 470 Watt
Electricity Production Toon = 0 Watt
Electricity LT counter from Toon = 4045973 Wh
Electricity NT counter from Toon = 3895103 Wh
Electricity Counter Toon Total = 7941076 Wh
Electricity production counter LT from Toon =  Wh
Electricity production counter NT from Toon =  Wh
Write new value 
{
   "status" : "OK",
   "title" : "Update Device"
the usage is right, how can i solve this
I sometimes get strang values when the meteradapter has been disconnected. Domoticz needs a day to adjust the values for some reason.
According to the debug echos the script is reading correct values now.
ArieKanarie
Posts: 41
Joined: Saturday 12 December 2015 13:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ArieKanarie »

I'm about to purchase a second hand toon to play with it en connect it to Domoticz.

Maybe a N00b question, but can I control more from domoticz than only the temperature?
As I learned Toon has a Zwave controller, so can I start buying Zwave devices to control them via Domoticz (through Toon)?
User avatar
gielie
Posts: 290
Joined: Tuesday 12 January 2016 11:40
Target OS: Raspberry Pi / ODroid
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gielie »

FunFair wrote: Friday 04 May 2018 21:03 I
gielie wrote: Thursday 03 May 2018 15:10 I have a strange problem with my Toon P1 script.
The return amount is way too high, about 1.8.10^16.
When i look at the script, it gives nothing, which is right.

Code: Select all

pi@raspberrypi:~/domoticz/scripts/php $ ./p1_meter_data_json.php
Request for FROM date: 03-05-2018
Now: 2018-05-03 15:06:46
Electricity Usage Counter Domoticz = 7941058 Wh
Electricity Production Counter Domoticz = 8110649752 Wh

Electricity Usage Toon = 470 Watt
Electricity Production Toon = 0 Watt
Electricity LT counter from Toon = 4045973 Wh
Electricity NT counter from Toon = 3895103 Wh
Electricity Counter Toon Total = 7941076 Wh
Electricity production counter LT from Toon =  Wh
Electricity production counter NT from Toon =  Wh
Write new value 
{
   "status" : "OK",
   "title" : "Update Device"
the usage is right, how can i solve this
I sometimes get strang values when the meteradapter has been disconnected. Domoticz needs a day to adjust the values for some reason.
According to the debug echos the script is reading correct values now.
I get this high value for a couple of days now and it is increasing while the production is 0 (no solar collectors connected)
- Aeon Labs USB Stick met Z-wave plus
- Aeotec MultiSensor 6
- FIBARO FGS223
- FIBARO FGWPE Wall Plug
- Neo CoolCam Power plug
- Popp Smoke Detector
- Toon
- Kodi Media Server
Stimpy68
Posts: 40
Joined: Wednesday 09 May 2018 16:37
Target OS: Linux
Domoticz version:
Location: The Hague, The Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Stimpy68 »

Hi, I've been running the lua script for some time now and it works great, but today I upgraded from the stable to the beta and now I have this error in the logs:

Code: Select all

Error: EventSystem: UpdateDevice IDX 0 not found!
When I disabled the Toon lua script, the error was gone. So what's the problem here?

Code: Select all

-- Time script runs every minute, intended to sync Domoticz with Toon in case the value is changed on the physical device.
-- Updates Toon Thermostat Sensor to value set on Toon
-- Updates Toon Temperature Sensor to value set on Toon
-- Updates Toon Scenes switch based on program set on Toon
-- Updates Toon Auto Program switch to value set on Toon
-- Updates Toon program information text to value set on Toon

commandArray = {}

    ToonThermostatSensorName = uservariables['UV_ToonThermostatSensorName'] -- Sensor showing current setpoint
    ToonTemperatureSensorName = uservariables['UV_ToonTemperatureSensorName'] -- Sensor showing current room temperature
    ToonScenesSensorName  = uservariables['UV_ToonScenesSensorName'] -- Sensor showing current program
    ToonAutoProgramSensorName = uservariables['UV_ToonAutoProgramSensorName'] -- Sensor showing current auto program status
    ToonProgramInformationSensorName = uservariables['UV_ToonProgramInformationSensorName'] -- Sensor showing displaying program information status
    ToonIP = uservariables['UV_ToonIP']
    DomoticzIP = uservariables['UV_DomoticzIP']

    json = assert(loadfile "/domoticz/scripts/lua/JSON.lua")()  -- For Windows

    local handle = assert(io.popen(string.format('curl http://%s/happ_thermstat?action=getThermostatInfo', ToonIP)))
        local ThermostatInfo = handle:read('*all')
    handle:close()

    jsonThermostatInfo = json:decode(ThermostatInfo)

    currentSetpoint = tonumber(jsonThermostatInfo.currentSetpoint) / 100
    currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
    currentProgramState = tonumber(jsonThermostatInfo.programState)
    currentActiveState = tonumber(jsonThermostatInfo.activeState)
    currentNextTime = jsonThermostatInfo.nextTime
    currentNextSetPoint = tonumber(jsonThermostatInfo.nextSetpoint) / 100

    -- Update the thermostat sensor to current setpoint
    if otherdevices_svalues[ToonThermostatSensorName]*100 ~= currentSetpoint*100 then
        print('Updating thermostat sensor to new set point: ' ..currentSetpoint)
        commandArray[1] = {['Variable:UV_ToonChangedByDomoticz'] = '1'} -- Set variable changed to 1 to prevent script ToonSetPoint from shooting an event at Toon
        commandArray[2] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonThermostatSensorName], currentSetpoint)}
    end

    -- Update the temperature sensor to current room temperature
    if otherdevices_svalues[ToonTemperatureSensorName]*100 ~= currentTemperature*100 then
        print('Updating the temperature sensor to new value: ' ..currentTemperature)
        commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonTemperatureSensorName], currentTemperature)}
    end

    -- Update the toon scene selector sensor to current program state
    CurrentToonScenesSensorValue = otherdevices_svalues[ToonScenesSensorName]

    if currentActiveState == -1 then currentActiveState = '50' -- Manual
    elseif currentActiveState == 0 then currentActiveState = '40' -- Comfort
    elseif currentActiveState == 1 then currentActiveState = '30' -- Home
    elseif currentActiveState == 2 then currentActiveState = '20' -- Sleep
    elseif currentActiveState == 3 then currentActiveState = '10' -- Away
    end

    if CurrentToonScenesSensorValue ~= currentActiveState then  -- Update toon selector if it has changed
        print ('Updating Toon Scenes selector')
        commandArray[4] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonScenesSensorName], currentActiveState)}
    end

    -- Updates the toon auto program switch
    CurrentToonAutoProgramSensorValue = otherdevices_svalues[ToonAutoProgramSensorName]

    if currentProgramState == 0 then currentProgramState = '10' -- No
    elseif currentProgramState == 1 then currentProgramState = '20' -- Yes
    elseif currentProgramState == 2 then currentProgramState = '30' -- Temporary
    end

    if CurrentToonAutoProgramSensorValue ~= currentProgramState then -- Update toon auto program selector if it has changed
        print ('Updating Toon Auto Program selector')
        commandArray[5] = {['UpdateDevice'] = string.format('%s|1|%s', otherdevices_idx[ToonAutoProgramSensorName], currentProgramState)}
    end

    -- Updates the toon program information text box
    CurrentToomProgramInformationSensorValue = otherdevices_svalues[ToonProgramInformationSensorName]
    if currentNextTime == 0 or currentNextSetPoint == 0 then
        ToonProgramInformationSensorValue = 'Op ' ..currentSetpoint.. '°'
    else
        ToonProgramInformationSensorValue = 'Om ' ..os.date('%H:%M', currentNextTime).. ' op ' ..currentNextSetPoint.. '°'
    end

    if CurrentToomProgramInformationSensorValue ~= ToonProgramInformationSensorValue then
        commandArray[6] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonProgramInformationSensorName], ToonProgramInformationSensorValue)}
    end

--

return commandArray
ArieKanarie
Posts: 41
Joined: Saturday 12 December 2015 13:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ArieKanarie »

When I try to access a url directly, I get a 403 - Forbidden page:
http://192.168.6.20/happ_thermstat?acti ... ureState=2

I have access to the Zwave webpage and ssh, so I assume the firewall is not the problem?

And additionally: wouldn't it be possible to replace the ugle pink TOON splash screen for something more fancy?
ArieKanarie
Posts: 41
Joined: Saturday 12 December 2015 13:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ArieKanarie »

THe 403 error is resolved.

Now The temperature won't get updated and i get this error in the log:

Code: Select all

2018-05-10 12:08:00.710 Error: dzVents: Error: ...moticz/scripts/dzVents/generated_scripts/ToonGetInfo.lua:52: attempt to index a nil value
2018-05-10 12:08:00.710 dzVents: Info: ------ Finished ToonGetInfo
2018-05-10 12:08:00.710 EventSystem: Fetching url...
2018-05-10 12:08:00.710 EventSystem: Script event triggered: /home/pi/domoticz/scripts/dzVents/runtime/dzVents.lua
2018-05-10 12:08:00.953 Error: Error opening url: http://127.0.0.1:8080/json.htm?type=command¶m=setsetpoint&idx=583&setpoint=15
ArieKanarie
Posts: 41
Joined: Saturday 12 December 2015 13:25
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ArieKanarie »

again answering myself:
Solved

Code: Select all

2018-05-10 12:08:00.953 Error: Error opening url: http://127.0.0.1:8080/json.htm?type=command¶m=setsetpoint&idx=583&setpoint=15
Problem was to add 127.0.0.* in the local networks (allow access without password)

The other error

Code: Select all

2018-05-10 12:08:00.710 Error: dzVents: Error: ...moticz/scripts/dzVents/generated_scripts/ToonGetInfo.lua:52: attempt to index a nil value
seems to resolved bu itself, it was still there but haven't seen it since the last 10 minutes.
Stimpy68
Posts: 40
Joined: Wednesday 09 May 2018 16:37
Target OS: Linux
Domoticz version:
Location: The Hague, The Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Stimpy68 »

Stimpy68 wrote: Wednesday 09 May 2018 16:44 Hi, I've been running the lua script for some time now and it works great, but today I upgraded from the stable to the beta and now I have this error in the logs:

Code: Select all

Error: EventSystem: UpdateDevice IDX 0 not found!
When I disabled the Toon lua script, the error was gone. So what's the problem here?
Anybody a clue?
michel30
Posts: 19
Joined: Tuesday 12 December 2017 21:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by michel30 »

After upgrading Domoticz Version 4.9700 (June 23th 2018) two Toon icons does not work anymore.

1: Toon Scenes
1.jpg
1.jpg (32.63 KiB) Viewed 3738 times
2: Toon Autoprogram
The attachment 2.jpg is no longer available
The two icons shows text in it:

I don't now how to fix it or where the issue is, this happend after the update of Domototicz 4.9700 before it works super.
Attachments
2.jpg
2.jpg (25.98 KiB) Viewed 3738 times
User avatar
gizmocuz
Posts: 2350
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gizmocuz »

Try editing your switch and label them correctly. (i assume you cleared the browser cache and appcache)
Quality outlives Quantity!
michel30
Posts: 19
Joined: Tuesday 12 December 2017 21:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by michel30 »

OMG :oops:

Thanks for your help now it works..
terrorsource
Posts: 67
Joined: Wednesday 10 May 2017 17:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by terrorsource »

The LUA script is triggered when there's a temperature change of 0.01 degrees, which causes a lot of logging in Domoticz.
How can i set that to 0.1 so it it decreases the logs?
Templar
Posts: 8
Joined: Wednesday 14 August 2013 14:59
Target OS: NAS (Synology & others)
Domoticz version: V4.9700
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Templar »

Darn, I am getting this error and my values aren't updated.

Code: Select all

 Error: EventSystem: in Toon: [string "-- Version 1:..."]:61: attempt to perform arithmetic on field '?' (a nil value)
This is line 61 of the Toon script:

Code: Select all

if otherdevices_svalues[ToonThermostatSensorName]*100 ~= currentSetpoint*100 then 
Does anybody know what the problem is?

EDIT: Never mind: solved it. Didn't execute de command "http://192.168.x.x:8080/json.htm?type=c ... 92.168.y.y" properly.
Last edited by Templar on Tuesday 31 July 2018 20:20, edited 1 time in total.
Synology DS114 NAS Domoticz package
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

terrorsource wrote: Monday 16 July 2018 9:50 The LUA script is triggered when there's a temperature change of 0.01 degrees, which causes a lot of logging in Domoticz.
How can i set that to 0.1 so it it decreases the logs?
I've changed to this

Code: Select all

       
local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
currentTemperature = tonumber(string.format("%.1f", currentTemperature))  -- 1 decimaal is voldoende
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
User avatar
madpatrick
Posts: 636
Joined: Monday 26 December 2016 12:17
Target OS: Linux
Domoticz version: 2024.7
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick »

FunFair wrote: Monday 05 March 2018 19:04
glsf91 wrote: Tuesday 06 February 2018 21:14 I have changed/made a PHP script which reads now the analog gas counter from RRD instead of CurrentGasQuantity from getDevices.json. This last one is reset to zero after reboot of Toon (and I think also after restarting the meter adapter).

The counter in RDD is alway increasing, so no strange high measurements in Domoticz after rebooting Toon. Only the first day is showing a high value now when you start using this, because of the current high value in RRD. That cannot be avoided as far as I know (unless resetting Toon).
I'am not a php developer so probably things can be done smarter. But it looks like it is working.
It is derived from analog_electricity_data_json.php, earlier in this thread.
Wow thanks! This is a much better solution than the previous one!!!!
It doesn't matter anymore if you have an analog or smart meter, as Toon writes the values in the same database.
I've used your code to clean up my versions and removed the comparisment incase Toon reported 'zero' values.

Tested these scripts with Toon version 4.9 and they work with:
- P1 Smart meter (including solar return)
- Analog/Digital Electricity meter
- Analog/Digital Gas meter

See file attached for who's interested.
Hi,

I've setup the scripts and i get the read outs, but i just want to be sure i've setup the dummy sensors correct.
Which one do i need to use, because there a several options for electricity.
For example for "electricity_data_json.php"
- Elektra (Aktueel+Teller)
- Verbruik (elektra)

(sorry, my setup is in Dutch)
I've read the whole post, but could not find it
-= HP server GEN8 Xeon(R) E3-1220L_V2 -=- OZW -=- Toon2 (rooted) -=- Domoticz v2024.7 -=- Dashticz v3.12b on Tab8" =-
Clinthighway
Posts: 1
Joined: Saturday 28 July 2018 13:44
Target OS: NAS (Synology & others)
Domoticz version:
Location: Vlaardingen - Zuid Holland
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Clinthighway »

Stimpy68 wrote: Thursday 31 May 2018 12:25
Stimpy68 wrote: Wednesday 09 May 2018 16:44 Hi, I've been running the lua script for some time now and it works great, but today I upgraded from the stable to the beta and now I have this error in the logs:

Code: Select all

Error: EventSystem: UpdateDevice IDX 0 not found!
When I disabled the Toon lua script, the error was gone. So what's the problem here?
Anybody a clue?
I have the same problem,

Code: Select all

EventSystem: UpdateDevice IDX 0 not found!
Using Domoticz on Synology with v4.9700
The "ToonThermostat" also not working
terrorsource
Posts: 67
Joined: Wednesday 10 May 2017 17:57
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by terrorsource »

madpatrick wrote: Saturday 28 July 2018 2:37
terrorsource wrote: Monday 16 July 2018 9:50 The LUA script is triggered when there's a temperature change of 0.01 degrees, which causes a lot of logging in Domoticz.
How can i set that to 0.1 so it it decreases the logs?
I've changed to this

Code: Select all

       
local currentTemperature = tonumber(jsonThermostatInfo.currentTemp) / 100
currentTemperature = tonumber(string.format("%.1f", currentTemperature))  -- 1 decimaal is voldoende
I'm using this script.
Can i change
string.format('%s|0|%s'
to
string.format('%.1f'
or is that not going to work?

Code: Select all

        if currentTemperature ~= nil then 
            -- Update the temperature sensor to current room temperature
            if otherdevices_svalues[ToonTemperatureSensorName]*100 ~= currentTemperature*100 then
                print('Updating the temperature sensor to new value: ' ..currentTemperature)
                commandArray[3] = {['UpdateDevice'] = string.format('%s|0|%s', otherdevices_idx[ToonTemperatureSensorName], currentTemperature)}
            end
        end
Itelemarc
Posts: 3
Joined: Monday 13 November 2017 16:48
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Itelemarc »

after the last domoticz update, i got the error:
scripts/dzVents/generated_scripts/600D Toon Setpoint.lua:8: attempt to concatenate field 'SetPoint' (a nil value)

ToonSetPoint

Code: Select all

return {
on = {
devices = {
'Toon Thermostat'
}
},
execute = function(domoticz, device)
domoticz.openURL(string.format('http://%s/happ_thermstat?action=setSetpoint&Setpoint=%s', domoticz.variables('UV_ToonIP').value, device.SetPoint*100))
domoticz.log('Setting Toon setpoint to '.. device.SetPoint)
end
}

After changing SetPoint to setPoint, it worked again.
This error is still so in the sample. So please correct.
User avatar
EdwinK
Posts: 1820
Joined: Sunday 22 January 2017 21:46
Target OS: Raspberry Pi / ODroid
Domoticz version: BETA
Location: Rhoon
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by EdwinK »

Templar wrote: Thursday 26 July 2018 23:43 Darn, I am getting this error and my values aren't updated.

Code: Select all

 Error: EventSystem: in Toon: [string "-- Version 1:..."]:61: attempt to perform arithmetic on field '?' (a nil value)
This is line 61 of the Toon script:

Code: Select all

if otherdevices_svalues[ToonThermostatSensorName]*100 ~= currentSetpoint*100 then 
Does anybody know what the problem is?

EDIT: Never mind: solved it. Didn't execute de command "http://192.168.x.x:8080/json.htm?type=c ... 92.168.y.y" properly.
For me, this error is on line 81

Code: Select all

  if otherdevices_svalues[ToonThermostatSensorName]*100 ~= currentSetpoint*100 then  
I tried the above command, changing it to my settings, to look like

Code: Select all

http://192.168.0.11:8080/json.htm?type=command&param=udevice&idx=1&nvalue=0&svalue=192.168.0.4
and got the 'device updated' message.

Not sure what IDX to use.
Running latest BETA on a Pi-3 | Toon® Thermostat (rooted) | Hue | Tuya | IKEA tradfri | Dashticz V3 on Lenovo Huawei Tablet | Conbee
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests