Hello Everybody,
I am trying to read and write several One-wire sensors into dummy temp sensors.
One-wire sensors are conected to a WEBCAI board, values I can receive with HTTP request
when I use the request an output it gives me value 23.2 C (where C is for Celsius, but this is coming from the web board)
Found this script allready on this site , but needs some rewriting for me to get it working.
I am a complete nob when it comes to programming, so desperate for some help with this.
commandArray = {}
now=os.date("*t")
-- NB : every 5 minutes only, if u prefer every 2 min or even every 1 min
-- change the 5 below
if now.min % 5 == 0 then
local f = assert(io.popen("curl -s http://x.x.x.x/gett2.cgi" , 'r'))
local s = assert(f:read('*a'))
local threeZero, status, temp = s:match("|([^|]*)|([^|]*)|([^|]*)|")
if status == "OK" then
-- you can see prints in Setup/Log
print("One-Wire : read and update 1 : "..s.."=>"..temp)
commandArray["UpdateDevice"] = IDX.."|0|"..temp
else
print("One-Wire : bad status : "..s)
end
end
return commandArray
I believe the error for my case is in the line : local threeZero, status, temp = s:match("|([^|]*)|([^|]*)|([^|]*)|")
but not sure. I am only getting 23.6 C as result also when I use a curl request directly.
Any help, much appriated
Jack
Import temperature sensor1 One-wire
Moderator: leecollings
-
- Posts: 18
- Joined: Thursday 10 May 2018 10:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V8.153
- Location: Oss The Netherlands
- Contact:
Import temperature sensor1 One-wire
5 x raspberry with Domoticz, open hab, Home assitant, OpenElec Kodi.
Interests Home automation
Interests Home automation
-
- Posts: 18
- Joined: Thursday 10 May 2018 10:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V8.153
- Location: Oss The Netherlands
- Contact:
Re: Import temperature sensor1 One-wire
Update on my request
changest the lua script
commandArray = {}
now=os.date("*t")
-- NB : every 5 minutes only, if u prefer every 2 min or even every 1 min
-- change the 5 below
if now.min % 5 == 0 then
local f = assert(io.popen("curl -u http://X.X.X.X/gett1.cgi" , 'r'))
local s = assert(f:read('*a'))
local temp = s:match("|([^|]*)|([^|]*)|")
if status == "OK" then
-- you can see prints in Setup/Log
print("One-Wire : read and update 1 : "..s"=>"..temp)
commandArray["UpdateDevice"] = '92|0|'..temp
else
print("One-Wire : bad status : "..s)
end
end
return commandArray
Now i am seeing in the log file
2018-05-13 14:30:01.095 dzVents: One-Wire : bad status : 23.0 C
So looks like the C behind the 23.0 is still given me a problem, because that not updating the virtual sensor.
How change to the import that it's not reading the C value.
Any suggestions would be very appriciated.
Jack
changest the lua script
commandArray = {}
now=os.date("*t")
-- NB : every 5 minutes only, if u prefer every 2 min or even every 1 min
-- change the 5 below
if now.min % 5 == 0 then
local f = assert(io.popen("curl -u http://X.X.X.X/gett1.cgi" , 'r'))
local s = assert(f:read('*a'))
local temp = s:match("|([^|]*)|([^|]*)|")
if status == "OK" then
-- you can see prints in Setup/Log
print("One-Wire : read and update 1 : "..s"=>"..temp)
commandArray["UpdateDevice"] = '92|0|'..temp
else
print("One-Wire : bad status : "..s)
end
end
return commandArray
Now i am seeing in the log file
2018-05-13 14:30:01.095 dzVents: One-Wire : bad status : 23.0 C
So looks like the C behind the 23.0 is still given me a problem, because that not updating the virtual sensor.
How change to the import that it's not reading the C value.
Any suggestions would be very appriciated.
Jack
5 x raspberry with Domoticz, open hab, Home assitant, OpenElec Kodi.
Interests Home automation
Interests Home automation
-
- Posts: 18
- Joined: Thursday 10 May 2018 10:14
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V8.153
- Location: Oss The Netherlands
- Contact:
Re: Import temperature sensor1 One-wire
Update
I have managed to get this Lua script working
Now the next goal is to get 9 of these script together in 1 lua script, to read and write 8 temp sensor and a humidity sensor
Any suggestions ? because I am a complete beginner when it comes to programming
Script would be
Start the timer (see above in start of script)
read T1
write T1
read T2
Write T2
etc..
Any help in the right direction is much appriciated
I have managed to get this Lua script working
Code: Select all
commandArray = {}
now=os.date("*t")
-- NB : every 5 minutes only, if u prefer every 2 min or even every 1 min
-- change the 5 below
if now.min % 5 == 0 then
local f = assert(io.popen("curl -u X:X http://192.168.X.X/gett1.cgi" , 'r'))
local s = assert(f:read('*a'))
-- local temp = s:match("|([^|]*)|([^|]*)|") was not working
local temp = s:match("|([^|]*)|")
-- take out all upercase characters of string --make str alpha-numeric because input string was 25.1 C and only need 25.1
if(s:match("%W")) then
s = s:gsub('%u','')
-- you can see prints in Setup/Log to see of it is reading
print("T1 = "..s)
-- -- sending the input s to the virtual sensor T1
-- print("T-1 : read and update 1 : "..s.. "=>"..temp) did not work this line
commandArray['UpdateDevice'] = '92|0|'..s
-- Now virtual sensor T1 is updated every 5 minutes
end
end
return commandArray
Any suggestions ? because I am a complete beginner when it comes to programming
Script would be
Start the timer (see above in start of script)
read T1
write T1
read T2
Write T2
etc..
Any help in the right direction is much appriciated
5 x raspberry with Domoticz, open hab, Home assitant, OpenElec Kodi.
Interests Home automation
Interests Home automation
Who is online
Users browsing this forum: No registered users and 1 guest