Domoticz temperature from another raspberri pi sensor
i do not know what i am doing wrong
but i do get only bad status
it is working
when i put
commandArray['UpdateDevice']='13|0|'..s
after the else on the bad side
i have domoticz on smartgridmeter raspberry pi 3b
i have temperature sensor on my desktop raspberry pi 3b+ running php webserver
lua script entered in domoticz editor called the script temp (temp lua time event active)
hardware idx7 dummy
devices type temp idx = 13
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 % 1 == 0 then
local f = assert(io.popen("curl -s http://84.106.2.21:8888/temperaturedom.php" , '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 13 : "..s.."=>"..temp)
commandArray['UpdateDevice']='13|0|'..temp
else
print("One-Wire : bad status : "..s)
-- whe are on the bad status side of else but this way its working for me next line should not be here
commandArray['UpdateDevice']='13|0|'..s
end
end
return commandArray
2018-10-23 16:06:01.706 (Slimme Meter Kabel) P1 Smart Meter (Power 12-4-2018)
2018-10-23 16:06:01.707 (Slimme Meter Kabel) General/Voltage (Voltage L1)
2018-10-23 16:06:01.354 Status: LUA: One-Wire : bad status :
2018-10-23 16:06:01.354
2018-10-23 16:06:01.354 22.50
2018-10-23 16:06:01.355 Status: EventSystem: Script event triggered: temp
2018-10-23 16:06:02.711 (Slimme Meter Kabel) P1 Smart Meter (Power 12-4-2018)
2018-10-23 16:06:02.713 (Slimme Meter Kabel) General/Voltage (Voltage L1)
2018-10-23 23:27:01.408 (Slimme Meter Kabel) General/Voltage (Voltage L1)
2018-10-23 23:27:01.461 Status: LUA: One-Wire : bad status : 23.50
2018-10-23 23:27:01.463 Status: EventSystem: Script event triggered: temp
the errors i get with the example on this page
2018-10-23 14:23:00.308 Error: EventSystem: in temperature: [string "commandArray = {}..."]:15: attempt to concatenate local 'temp' (a nil value)
2018-10-23 14:36:00.439 Error: EventSystem: in temperature: [string "commandArray = {}..."]:15: attempt to concatenate global 'tempy' (a nil valu
2018-10-23 15:01:00.213 Error: EventSystem: in temperature: [string "commandArray = {}..."]:18: attempt to concatenate global 's' (a nil value)
2018-10-23 15:26:01.438 Error: EventSystem: in temperature: [string "commandArray = {}..."]:19: attempt to concatenate global 's' (a nil value)
2018-10-23 15:40:01.117 Error: EventSystem: in temp: [string "commandArray = {}..."]:17: attempt to concatenate local 'temp' (a nil value)
code i use for writing sensor data to php webpage (not the domoticz raspberrypi, another one wich i use as desktop computer)
http://84.106.2.21:8888/temperaturedom.php
Code: Select all
<?php
$file = '/sys/devices/w1_bus_master1/28-00000a2a21f8/w1_slave';
$lines = file($file);
$temp = explode('=', $lines[1]);
$temp = number_format($temp[1] / 1000, 2, '.', '');
echo $temp;
?>
http://test:[email protected]:8080/#/Dashboard