Controlling Toon [HACKED] from Domoticz

For heating/cooling related questions in Domoticz
User avatar
gielie
Posts: 225
Joined: Tuesday 12 January 2016 12:40
Target OS: Raspberry Pi
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gielie » 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
- Vision ZU1401 USB Stick
- Aeotec MultiSensor 6
- FIBARO FGS222
- FIBARO FGWPE Wall Plug
- Everspring AN157
- Neo CoolCam Power plug
- Neo CoolCam PIR Sensor
- Popp Smoke Detector
- Toon
- Kodi Media Server

FunFair
Posts: 37
Joined: Wednesday 04 October 2017 11:29
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by FunFair » 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.

ArieKanarie
Posts: 48
Joined: Saturday 12 December 2015 14:25
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ArieKanarie » Monday 07 May 2018 12:23

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: 225
Joined: Tuesday 12 January 2016 12:40
Target OS: Raspberry Pi
Domoticz version: latest β
Location: The Netherlands (Alkmaar)
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gielie » Monday 07 May 2018 14:44

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)
- Vision ZU1401 USB Stick
- Aeotec MultiSensor 6
- FIBARO FGS222
- FIBARO FGWPE Wall Plug
- Everspring AN157
- Neo CoolCam Power plug
- Neo CoolCam PIR Sensor
- Popp Smoke Detector
- Toon
- Kodi Media Server

Stimpy68
Posts: 11
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 » 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?

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: 48
Joined: Saturday 12 December 2015 14:25
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ArieKanarie » Thursday 10 May 2018 0:08

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: 48
Joined: Saturday 12 December 2015 14:25
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ArieKanarie » Thursday 10 May 2018 12:12

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: 48
Joined: Saturday 12 December 2015 14:25
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by ArieKanarie » Monday 14 May 2018 12:08

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: 11
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 » 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?

michel30
Posts: 20
Joined: Tuesday 12 December 2017 22:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by michel30 » Tuesday 26 June 2018 22:32

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 1188 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 1188 times

User avatar
gizmocuz
Posts: 8688
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi
Domoticz version: beta
Location: Top of the world
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by gizmocuz » Wednesday 27 June 2018 8:24

Try editing your switch and label them correctly. (i assume you cleared the browser cache and appcache)
Quality outlives Quantity!

michel30
Posts: 20
Joined: Tuesday 12 December 2017 22:00
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by michel30 » Wednesday 27 June 2018 21:17

OMG :oops:

Thanks for your help now it works..

terrorsource
Posts: 58
Joined: Wednesday 10 May 2017 17:57
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by terrorsource » 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?

Templar
Posts: 18
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 » 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.
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: 49
Joined: Monday 26 December 2016 13:17
Target OS: Linux
Domoticz version: 4.9700
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick » 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
ClearOS 7.5.0 - Toon 4.15.16 (rooted) - Domoticz 4.9700

User avatar
madpatrick
Posts: 49
Joined: Monday 26 December 2016 13:17
Target OS: Linux
Domoticz version: 4.9700
Location: Netherlands
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by madpatrick » Saturday 28 July 2018 5:06

FunFair wrote:
Monday 05 March 2018 20:04
glsf91 wrote:
Tuesday 06 February 2018 22: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
ClearOS 7.5.0 - Toon 4.15.16 (rooted) - Domoticz 4.9700

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 » Saturday 28 July 2018 13:58

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: 58
Joined: Wednesday 10 May 2017 17:57
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by terrorsource » Sunday 29 July 2018 22:21

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: 4
Joined: Monday 13 November 2017 17:48
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by Itelemarc » Sunday 23 September 2018 11:04

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: 1317
Joined: Sunday 22 January 2017 22:46
Target OS: Raspberry Pi
Domoticz version: Beta
Location: Rhoon
Contact:

Re: Controlling Toon [HACKED] from Domoticz

Post by EdwinK » Sunday 23 September 2018 12:09

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) | RFxcom | Dashticz V2 |

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests