new: KMTronic USB/485/TCP(Web) support

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

User avatar
RATA1
Posts: 19
Joined: Tuesday 08 December 2015 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Taunton, UK
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by RATA1 »

This is what the script outputs for me from the gui. It is fine - if you don't get this but can browse to it from the same machine domoticz is on then don't know. If the two are on different networks you need to route between them.
I don't use windows so can't help with that platform but the script is fine on a pi ;)
Good luck maybe Santa will bring you a pi. Image

Sent from my SM-G935F using Tapatalk

Pi + RFX433 + AEOTEC Gen5 ZWave + HGI80 + CM180i + sensors
SolarEdge Inverter and PVOutput
mcgiak
Posts: 18
Joined: Sunday 24 December 2017 10:15
Target OS: -
Domoticz version: 2023.2
Location: Veneto, Italy
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by mcgiak »

I have pi model b and pi3 model b (used with kodi and retropie)
tomorrow i write a sdcard with raspbian jessie and install domoticz.

there is a router between two networks, from the broswer i have access

the temperature board is also accessible from outside the network (i can give you the adress via PM and you can try your script with my board?)

Thank you very much!

Again merry christmas to you
User avatar
RATA1
Posts: 19
Joined: Tuesday 08 December 2015 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Taunton, UK
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by RATA1 »

Hello,
Now that I had 5 mins to sit down and have a look the issue is that the virtual switch names were not changed and it was throwing an error but was for some reason not showing in the log file - maybe a bit different the way it does things when running Domoticz on Windows?

They need to be what your switch names are.

I have posted the modified script below and perhaps easier to modify/understand. I have PM'ed it to you too.

------------------------------------------------------------------------------
--
--
-- Domoticz lua script to convert XML output from KMTronic DS1820 LAN module
-- Reads the temperature based on the unique ID of the sensor and passes it
-- back to a virtual temperature sensor(s)
-- sensors in Domoticz
--
------------------------------------------------------------------------------
-- Rob Allen 12/04/2016
-- re written for "universal use" 25/12/2017
------------------------------------------------------------------------------

commandArray = {}



function XML_Capture(cmd,flatten)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if flatten then
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
end
return s
end

--set to true to print to log file.
debug = true


--Dummy switch names - important to get these to match - change as appropriate to YOUR Virtual switches you already created
Dummy_Switch_Name_1 = "ACS"
Dummy_Switch_Name_2 = "Interna"
Dummy_Switch_Name_3 = "Puffer"
Dummy_Switch_Name_4 = "Esterna"

--or comment out above uncomment below and edit your IDX numbers of YOUR Virtual switches you already created


--Dummy_Switch_Name_1 = 644
--Dummy_Switch_Name_2 = 645
--Dummy_Switch_Name_3 = 646
--Dummy_Switch_Name_4 = 647



--define temperature sensor UID's - i.e. the DS1820 serial number
--up to 4 per DS1820 LAN interface

sensorID_1 = "28FFA4555115031C"
sensorID_2 = "28FF228C541503EC"
sensorID_3 = "28FFE28B54150348"
sensorID_4 = "28FF0E8B541503B3"


-- Define your device IP@

Device_IP = "192.168.1.199" -- change this to the internal IP@ of KMtronic box

if debug == true then
print("Reading values from: 'http://"..Device_IP.."/status.xml'")
end

-- Read the XML data from the device

XML_string=XML_Capture("curl -s 'http://"..Device_IP.."/status.xml'",1)


valid = string.find(XML_string, "<response>") -- check we are looking in the right place

if debug == true then
print(XML_string)
end

if valid == nil then
print ("Bad XML status read - temperatures NOT updated")
else

--Find the first sensor based on its UID

i = string.find(XML_string,sensorID_1) -- find the unique ID of the sensor
p = string.find(XML_string,"<temp>",i) --look for the next occurrence of <temp> after ID

TempTemperature1=string.sub(XML_string,p+6,p+10) --temperature is the 5 characters after <temp> - i.e. 6-10

commandArray[1] = {['UpdateDevice'] = Dummy_Switch_Name_1.."|0|"..TempTemperature1} --send updated values to Domoticz - must make sure the name matches the Dummy name you created above.

if debug == true then
print("Temp returned for "..Dummy_Switch_Name_1.." = '"..TempTemperature1.."'")
end



-- Second sensor based on its UID

i = string.find(XML_string, sensorID_2) -- find the next unique ID of the sensor
p = string.find(XML_string,"<temp>",i) --look for the next occurrence of <temp> after ID

TempTemperature2=string.sub(XML_string,p+6,p+10) --temperature is the 5 characters after <temp> - i.e. 6-10

commandArray[2] = { ['UpdateDevice'] = Dummy_Switch_Name_2.."|0|"..TempTemperature2 } --send updated values to Domoticz

if debug == true then
print("Temp returned for "..Dummy_Switch_Name_2.." = '"..TempTemperature2.."'")
end

-- Third sensor based on its UID


i = string.find(XML_string, sensorID_3) -- find the next unique ID of the sensor
p = string.find(XML_string,"<temp>",i) --look for the next occurrence of <temp> after ID


TempTemperature3=string.sub(XML_string,p+6,p+10) --temperature is the 5 characters after <temp> - i.e. 6-10

commandArray[3] = {['UpdateDevice'] = Dummy_Switch_Name_3.."|0|"..TempTemperature3 } --send updated values to Domoticz

if debug == true then
print("Temp returned for "..Dummy_Switch_Name_3.." = '"..TempTemperature3.."'")
end


-- Fourth sensor based on its UID

i = string.find(XML_string, sensorID_4) -- find the next unique ID of the sensor
p = string.find(XML_string,"<temp>",i) --look for the next occurrence of <temp> after ID

TempTemperature4=string.sub(XML_string,p+6,p+10) --temperature is the 5 characters after <temp> - i.e. 6-10

commandArray[4] = { ['UpdateDevice'] = Dummy_Switch_Name_4.."|0|"..TempTemperature4 } --send updated values to Domoticz

if debug == true then
print("Temp returned for "..Dummy_Switch_Name_4.." = '"..TempTemperature4.."'")
end


end




return commandArray
Pi + RFX433 + AEOTEC Gen5 ZWave + HGI80 + CM180i + sensors
SolarEdge Inverter and PVOutput
mcgiak
Posts: 18
Joined: Sunday 24 December 2017 10:15
Target OS: -
Domoticz version: 2023.2
Location: Veneto, Italy
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by mcgiak »

Thank you for yout work and your disponibility!

Sorry, i'm late :\

I have changed the script code and insert the new code, but in the log i have the same message:

2017-12-29 17:51:00.465 LUA: Bad XML status read - temperatures NOT updated
2017-12-29 17:52:00.171 LUA: Bad XML status read - temperatures NOT updated
2017-12-29 17:53:00.501 LUA: Bad XML status read - temperatures NOT updated

It's possible?
User avatar
RATA1
Posts: 19
Joined: Tuesday 08 December 2015 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Taunton, UK
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by RATA1 »

Hello,
check all the error logs (not just the status) and make sure you have defined/created the virtual switches with what is in the code in the quotes - i.e. below.

Dummy_Switch_Name_1 = "ACS"
Dummy_Switch_Name_2 = "Interna"
Dummy_Switch_Name_3 = "Puffer"
Dummy_Switch_Name_4 = "Esterna"

It should be a copy and paste exercise and all you need to to is define/create what is needed in terms of dummy switches. If the dummy switches are not defined or wrong it will throw an error (that I am guessing you can't see in the info log) and print the "not updated". The script above works fine on my platform when using the public @ of your KMtronic box so it is something to do with your setup rather than the script or the KMtronic box.

Thanks
Pi + RFX433 + AEOTEC Gen5 ZWave + HGI80 + CM180i + sensors
SolarEdge Inverter and PVOutput
User avatar
RATA1
Posts: 19
Joined: Tuesday 08 December 2015 15:52
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Taunton, UK
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by RATA1 »

OK, For watchers here - did a TeamViewer session with mcgiak and the issue appears to be that cURL was not installed on the Windows box so failed to get anything back from the KMTronics module from the "curl" in the LUA script and fails with the:

"LUA: Bad XML status read - temperatures NOT updated"

Sadly there is no indication of failure due to curl not installed/working in the error logs (that I could see in the Window platform) ;(

I also made an error with the names or IDX. It needs to be the IDX value not the name. Sorry about the confusion there! The names can be used to reference the IDX for ease of debug.
Also there were no virtual switches created on mcgiak's install - it was pure vanilla:(

Below is the hopefully last update! We got it working on a fresh Pi install not the original Windows one so if you are having issues with it and on Windows OS I expect you will need to install cURL. I don't know and can't help there.

Thanks!
------------------------------------------------------------------------------
--
--
-- Domoticz lua script to convert XML output from KMTronic DS1820 LAN module
-- Reads the temperature based on the unique ID of the sensor and passes it
-- back to a virtual temperature sensor(s)
-- sensors in Domoticz
--
------------------------------------------------------------------------------
-- Rob Allen 12/04/2016
-- re written for "universal use" 25/12/2017
— corrected error with nave v IDX 29/12/2017
------------------------------------------------------------------------------

commandArray = {}



function XML_Capture(cmd,flatten)
local f = assert(io.popen(cmd, 'r'))
local s = assert(f:read('*a'))
f:close()
if flatten then
s = string.gsub(s, '^%s+', '')
s = string.gsub(s, '%s+$', '')
s = string.gsub(s, '[\n\r]+', ' ')
end
return s
end

--set to true to print to log file.
debug = false


--Dummy switch names - change as appropriate to YOUR Virtual switches you already created - used for meaningful debug output
Dummy_Switch_Name_1 = "Name1"
Dummy_Switch_Name_2 = "Name2"
Dummy_Switch_Name_3 = "Name3"
Dummy_Switch_Name_4 = "Name4"

—below edit the IDX numbers marked ?? with YOUR virtual switches you already created


--Dummy_Switch_IDX_1 = ?? -- replace with your dummy switch IDX of Dummy_Switch_Name_1 above
--Dummy_Switch_IDX_2 = ?? --replace with your dummy switch IDX of Dummy_Switch_Name_2 above
--Dummy_Switch_IDX_3 = ?? --replace with your dummy switch IDX of Dummy_Switch_Name_3 above
--Dummy_Switch_IDX_4 = ?? --replace with your dummy switch IDX of Dummy_Switch_Name_4 above



--define temperature sensor UID's - i.e. the DS1820 serial number
--up to 4 per DS1820 LAN interface

sensorID_1 = “1234567890AAAAAA"
sensorID_2 = “1234567890BBBBBB"
sensorID_3 = “1234567890CCCCCC"
sensorID_4 = “1234567890DDDDDD"


-- Define your device IP@

Device_IP = "192.168.1.199" -- change this to the internal IP@ of KMtronic box

if debug == true then
print("Reading values from: 'http://"..Device_IP.."/status.xml'")
end

-- Read the XML data from the device

XML_string=XML_Capture("curl -s 'http://"..Device_IP.."/status.xml'",1)


valid = string.find(XML_string, "<response>") -- check we are looking in the right place

if debug == true then
print(XML_string)
end

if valid == nil then
print ("Bad XML status read - temperatures NOT updated")
else

--Find the first sensor based on its UID

i = string.find(XML_string,sensorID_1) -- find the unique ID of the sensor
p = string.find(XML_string,"<temp>",i) --look for the next occurrence of <temp> after ID

TempTemperature1=string.sub(XML_string,p+6,p+10) --temperature is the 5 characters after <temp> - i.e. 6-10

commandArray[1] = {['UpdateDevice'] = Dummy_Switch_Name_1.."|0|"..TempTemperature1} --send updated values to Domoticz - must make sure the name matches the Dummy name you created above.

if debug == true then
print("Temp returned for "..Dummy_Switch_IDX_1.." = '"..TempTemperature1.."'")
end



-- Second sensor based on its UID

i = string.find(XML_string, sensorID_2) -- find the next unique ID of the sensor
p = string.find(XML_string,"<temp>",i) --look for the next occurrence of <temp> after ID

TempTemperature2=string.sub(XML_string,p+6,p+10) --temperature is the 5 characters after <temp> - i.e. 6-10

commandArray[2] = { ['UpdateDevice'] = Dummy_Switch_IDX_2.."|0|"..TempTemperature2 } --send updated values to Domoticz

if debug == true then
print("Temp returned for "..Dummy_Switch_Name_2.." = '"..TempTemperature2.."'")
end

-- Third sensor based on its UID


i = string.find(XML_string, sensorID_3) -- find the next unique ID of the sensor
p = string.find(XML_string,"<temp>",i) --look for the next occurrence of <temp> after ID


TempTemperature3=string.sub(XML_string,p+6,p+10) --temperature is the 5 characters after <temp> - i.e. 6-10

commandArray[3] = {['UpdateDevice'] = Dummy_Switch_IDX_3.."|0|"..TempTemperature3 } --send updated values to Domoticz

if debug == true then
print("Temp returned for "..Dummy_Switch_Name_3.." = '"..TempTemperature3.."'")
end


-- Fourth sensor based on its UID

i = string.find(XML_string, sensorID_4) -- find the next unique ID of the sensor
p = string.find(XML_string,"<temp>",i) --look for the next occurrence of <temp> after ID

TempTemperature4=string.sub(XML_string,p+6,p+10) --temperature is the 5 characters after <temp> - i.e. 6-10

commandArray[4] = { ['UpdateDevice'] = Dummy_Switch_IDX_4.."|0|"..TempTemperature4 } --send updated values to Domoticz

if debug == true then
print("Temp returned for "..Dummy_Switch_Name_4.." = '"..TempTemperature4.."'")
end


end




return commandArray
Pi + RFX433 + AEOTEC Gen5 ZWave + HGI80 + CM180i + sensors
SolarEdge Inverter and PVOutput
dulka
Posts: 8
Joined: Thursday 01 March 2018 23:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by dulka »

I would like to get a DS18B20 kmtronic sensor that I have on my PI3 but I can not. I compiled the script by copying that of RATA1 and I have a problem. I inserted the modified script with a text editor of windows but nothing happens, the script is ignored, after having lost a lot of time I realized that the same script inserted in the folder of domoticz for windows is activated ... Why? do? Am I wrong to modify it with a text editor? Thanks to those who will help me.
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: new: KMTronic USB/485/TCP(Web) support

Post by gizmocuz »

In the next beta version (currently building) support has been added for the KMTronic temperature sensors.

https://github.com/domoticz/domoticz/co ... 0ba68bc830

Not sure why people are going very complicated with complex scripts while implementing this took less then 5 minutes in the native code :mrgreen:
Quality outlives Quantity!
dulka
Posts: 8
Joined: Thursday 01 March 2018 23:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by dulka »

In my situation this happens because i’m not so good. I hope that the kmtronic temp will be implemented as soon as possible within this nice program. I like it so much that I contributed to the financing. Thank you
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: new: KMTronic USB/485/TCP(Web) support

Post by gizmocuz »

@Dulka, thanks ! If you update to the latest beta version it should work. Just add the KMTronic TCP hardware
Quality outlives Quantity!
dulka
Posts: 8
Joined: Thursday 01 March 2018 23:12
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by dulka »

I have done it and it works. Tank you very much!!!!
jono
Posts: 21
Joined: Saturday 09 July 2016 8:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: U.K.-England
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by jono »

Hi my 8.channel kmtronic web relay keeps going idle after a period of time

I have to reset Domoticz to wake up the the relay any ideas

I’m using the latest beta version

Thank in advance
John


Sent from my iPhone using Tapatalk
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: new: KMTronic USB/485/TCP(Web) support

Post by gizmocuz »

Looking at the code, it also tries to poll every 10 seconds the relay status, so it can not be a timeout problem.
It could be a firmware issue, try to see if there is a new firmware
Make sure the device has a fixed IP address, as well as Domoticz
Quality outlives Quantity!
mcgiak
Posts: 18
Joined: Sunday 24 December 2017 10:15
Target OS: -
Domoticz version: 2023.2
Location: Veneto, Italy
Contact:

Re: new: KMTronic USB/485/TCP(Web) support

Post by mcgiak »

gizmocuz wrote: Saturday 10 March 2018 9:48 In the next beta version (currently building) support has been added for the KMTronic temperature sensors.

https://github.com/domoticz/domoticz/co ... 0ba68bc830

Not sure why people are going very complicated with complex scripts while implementing this took less then 5 minutes in the native code :mrgreen:
At the moment I use the 4.9700 version and the native support for the KMTronic Temperature board does not seem to be present. Am I wrong?
I am using the lua script at the moment, but unfortunately (and I can not understand why), domoticz does not send notifications although correctly set (sends them to other sensors).
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: new: KMTronic USB/485/TCP(Web) support

Post by gizmocuz »

@mcgiak , send you a PM for a debug request
Quality outlives Quantity!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests