Page 2 of 4
Re: Luftdaten
Posted: Friday 01 June 2018 21:21
by svde
The name in your first post when you declare a virtual dummy device in Domoticz has to start with: Luftdaten...
The name of the dummy devices needs to match the name in the script. If you give the devices different names, then you'll need to edit the script to match.
Thanks for the feedback, I've edited the first post in the thread.
Re: Luftdaten
Posted: Sunday 03 June 2018 19:52
by PieterS
Thank YOU very much for spreading your knowledge. I am glad with the easy reading of the results from the sensor.

Re: Luftdaten
Posted: Thursday 31 January 2019 20:39
by DuDo
svde wrote: Thursday 10 May 2018 16:34
dzVents script to retreive sensor data from my
https://luftdaten.info sensor. This script uses features which are not available in the current stable version of Domoticz (3.8153), you'll need to upgrade to beta to use this script.
My luftdaten device contains SDS10, DHT22 and BME280 sensors. I created 4 dummy devices (name of the devices needs to match the names in the script):
- Name: "Luftdaten PM10", Type: custom sensor, X-axis: µg/m3
- Name: "Luftdaten PM2.5", Type: custom sensor, X-axis: µg/m3
- Name: "Luftdaten DHT22", Type: Temp + Humidity
- Name: "Luftdaten BME280", Type: Temp + Humidity + Baro, (optional sensor)
Code: Select all
local FQDN = 'luftdaten.xxxx.xx'
return {
active = true,
on = {
timer = { 'every minute' },
httpResponses = { 'luftdatenRetrieved' } -- matches callback string below
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'http://' .. FQDN .. '/data.json',
method = 'GET',
callback = 'luftdatenRetrieved'
})
elseif (item.isHTTPResponse) then
if (item.ok and item.isJSON) then -- statusCode == 2xx
if tonumber(item.json.age) < 60 then
-- 1: SDS_P1 PM10, 2: SDS_P2 PM2.5, 3: DHT22 temp, 4: DHT22 hum, 5: BME280 temp, 6: BME280 hum, 7: BME280 baro
domoticz.devices('Luftdaten PM10').updateCustomSensor(item.json.sensordatavalues[1].value)
domoticz.devices('Luftdaten PM2.5').updateCustomSensor(item.json.sensordatavalues[2].value)
domoticz.devices('Luftdaten DHT22').updateTempHum(item.json.sensordatavalues[3].value,item.json.sensordatavalues[4].value,0)
-- Comment out the next 3 lines if you dont have the BME280 sensor
if (tonumber (item.json.sensordatavalues[5].value) < 100) and (tonumber (item.json.sensordatavalues[7].value)/100 < 1050) then
domoticz.devices('Luftdaten BME280').updateTempHumBaro(item.json.sensordatavalues[5].value,item.json.sensordatavalues[6].value,0,(item.json.sensordatavalues[7].value/100),0)
end
end
else
-- oops
domoticz.log('Error fetching Luftdaten data', domoticz.LOG_ERROR)
domoticz.log(item.data, domoticz.LOG_ERROR)
end
end
end
}
Download links for script with different sensors:
2018.06.30: added extra check on the values coming from the BME280 sensor. I'm sometimes getting erratic readings and I don't want those to be uploaded to domoticz.
2018.10.18: added download links for scripts with different sensors.
i use this script and did only a copy past and it works but there are a few problems
i do not have a graph i just get "undefined"
also with the bme280 sensor i also get no graph and the text {{ ::'Day' | translate }} and {{ ::'Month' | translate }}
also the baro is working when i click that i get a graph.......
i only copy pasted so no fault there.
i am running beta version 4.10366 on a raspberry pi zero w
Re: Luftdaten
Posted: Thursday 16 May 2019 16:49
by dude
Hi thanks for this super dzEvents script
It works for me. I've one additional question; I've not one but two Luftdaten sensors up and running and want to have the info of both sensors in Domoticz. Simple copy and run two scripts next to each other doesn't work. I'm a novice on dzEvents scripts an started to read read the wiki. But can somebody give me a hint how to retrieve and display the information for more than one sensor ?
Thanks in advance
Re: Luftdaten
Posted: Thursday 16 May 2019 17:10
by emme
why don't move to EspEasy Mega that support the same Dust sensor and can send directly to Domoticz via HTTP or MQTT?
Re: Luftdaten
Posted: Thursday 16 May 2019 18:58
by svde
dude wrote: Thursday 16 May 2019 16:49
Hi thanks for this super dzEvents script
It works for me. I've one additional question; I've not one but two Luftdaten sensors up and running and want to have the info of both sensors in Domoticz. Simple copy and run two scripts next to each other doesn't work.
If each sensor has a unique hostname and domoticz device names, then it should work.
Re: Luftdaten
Posted: Thursday 16 May 2019 21:19
by dude
Thx svde,
If each sensor has a unique hostname and domoticz device names, then it should work.
I'm using different IP addresses instead of hostname, And yes I'm using different device names;
- Luftdaten PM10 - Carport
Luftdaten PM10 - Terras
Both devices reports the same sensor value and they report the value from the latest started script conform log. same counts for the PM 2.5 values
2019-05-16 20:59:02.391 Status: dzVents: Info: Handling httpResponse-events for: "luftdatenRetrieved
2019-05-16 20:59:02.391 Status: dzVents: Info: ------ Start internal script: luftdaten-47: HTTPResponse: "luftdatenRetrieved"
2019-05-16 20:59:02.397 Status: dzVents: Info: ------ Finished luftdaten-47
2019-05-16 20:59:02.397 Status: dzVents: Info: ------ Start internal script: Luftdaten-55: HTTPResponse: "luftdatenRetrieved"
2019-05-16 20:59:02.398 Status: dzVents: Info: ------ Finished Luftdaten-55
After further research, i noticed the async HTTP calls are interfering. So by using different names in callback and httpResponse. My issue was solved. Running now two sensors simultaneous. THX !
@ emme, thx for your suggestion. I like to report my values to the central Luftdaten dbase. This will be difficult with EspEasy i think
Re: Luftdaten
Posted: Saturday 23 November 2019 13:43
by jonathan12
How can i find the URL of my sensor? luftdaten.xxx.com
Re: Luftdaten
Posted: Saturday 23 November 2019 15:11
by svde
jonathan12 wrote: Saturday 23 November 2019 13:43
How can i find the URL of my sensor? luftdaten.xxx.com
on my network systems names are automatically registered in (m)dns. I use the (short) hostname (only "luftdaten") in the script. If that doesn't happen on your network, then it may be a good idea to assign a static IP-address for the sensor and use that IP-address as the fqdn.
I've also changed the script as it seems that the senor has changed the order of the values.
Re: Luftdaten [SOLVED]
Posted: Sunday 22 December 2019 12:54
by beamzer
For people with an BME280 sensor on their Luftdaten sensor...
Apparently with one of the updates, the values of humidity and pressure swapped in the json output.
Pressure data now comes before Humidity:
Code: Select all
curl http://---IP ADDRESS---/data.json
{"software_version": "NRZ-2019-125-B1", "age":"65", "sensordatavalues":[{"value_type":"SDS_P1","value":"826.93"},{"value_type":"SDS_P2","value":"95.77"},{"value_type":"BME280_temperature","value":"10.68"},{"value_type":"BME280_pressure","value":"98219.00"},{"value_type":"BME280_humidity","value":"90.94"},{"value_type":"samples","value":"2491522"},{"value_type":"min_micro","value":"55"},{"value_type":"max_micro","value":"370429"},{"value_type":"signal","value":"-9"}]}
So the dzVents script has to be slightly modified:
Code: Select all
return {
active = true,
on = {
timer = { 'every minute' },
httpResponses = { 'luftdatenRetrieved' } -- matches callback string below
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'http://---IP ADDRESS---/data.json',
method = 'GET',
callback = 'luftdatenRetrieved'
})
elseif (item.isHTTPResponse) then
if (item.ok and item.isJSON) then -- statusCode == 2xx
if tonumber(item.json.age) < 60 then
-- OLD: 1: SDS_P1 PM10, 2: SDS_P2 PM2.5, 3: BME280 temp, 4: BME280 hum, 5: BME280 baro
-- 1: SDS_P1 PM10, 2: SDS_P2 PM2.5, 3: BME280 temp, 4: BME280 baro, 5: BME280 hum
domoticz.devices('Luftdaten PM10').updateCustomSensor(item.json.sensordatavalues[1].value)
domoticz.devices('Luftdaten PM2.5').updateCustomSensor(item.json.sensordatavalues[2].value)
if (tonumber (item.json.sensordatavalues[3].value) < 100) and (tonumber (item.json.sensordatavalues[5].value) < 105000) then
-- domoticz.devices('Luftdaten BME280').updateTempHumBaro(item.json.sensordatavalues[3].value,item.json.sensordatavalues[4].value,0,(item.json.sensordatavalues[5].value/100),0)
domoticz.devices('Luftdaten BME280').updateTempHumBaro(item.json.sensordatavalues[3].value,item.json.sensordatavalues[5].value,0,(item.json.sensordatavalues[4].value/100),0)
end
end
else
-- oops
domoticz.log('Error fetching Luftdaten data', domoticz.LOG_ERROR)
domoticz.log(item.data, domoticz.LOG_ERROR)
end
end
end
}
Ewald....
Re: Luftdaten
Posted: Saturday 25 April 2020 1:48
by MJAvH
Hello,
This script uses features which are available in the current stable version of Domoticz 2020.1 and dzVents Version: 3.0.1?
Or I need to upgrade to latest beta?
I'm asking because in my case I have this in logs:
Code: Select all
2020-04-25 01:44:00.652 Status: dzVents: Info: Handling httpResponse-events for: "luftdatenRetrieved"
2020-04-25 01:44:00.653 Status: dzVents: Info: ------ Start internal script: Script 02 Luftdaten: HTTPResponse: "luftdatenRetrieved"
2020-04-25 01:44:00.654 Status: dzVents: Info: ------ Finished Script 02 Luftdaten
And notnig else.
All virtual sensors were correctly created and are present in Domoticz
Thx for your suggestions.
Re: Luftdaten
Posted: Saturday 25 April 2020 8:55
by svde
MJAvH wrote: Saturday 25 April 2020 1:48
This script uses features which are available in the current stable version of Domoticz 2020.1 and dzVents Version: 3.0.1?
Or I need to upgrade to latest beta?
It should work with 2020.1. I just updated the text on the initial post. Thanks for mentioning this.
I'm asking because in my case I have this in logs:
Code: Select all
2020-04-25 01:44:00.652 Status: dzVents: Info: Handling httpResponse-events for: "luftdatenRetrieved"
2020-04-25 01:44:00.653 Status: dzVents: Info: ------ Start internal script: Script 02 Luftdaten: HTTPResponse: "luftdatenRetrieved"
2020-04-25 01:44:00.654 Status: dzVents: Info: ------ Finished Script 02 Luftdaten
And notnig else.
All virtual sensors were correctly created and are present in Domoticz
Thx for your suggestions.
Interesting. We'll need to troubleshoot a bit...
Re: Luftdaten
Posted: Wednesday 05 August 2020 22:06
by Benneton
Hi
Thank you very much svde!!
Copied your script and adopted it to my home situation ans it worked straight away.
I have version 2020.2.
Bernard
Re: Luftdaten
Posted: Wednesday 12 August 2020 12:56
by WvdM78
I am trying to add a luftdaten sensor near my street (not my own) in domoticz via public url. Could you help me which url needs to be inserted in the script? It appears that the api of luftdaten is migrated to sensor.community?
I have found
http://data.sensor.community/airrohr/v1 ... /<sensorid> but this doesn't work (yet).
Thanks in advance. I am using Domoticz 2020.2 beta 12221.
Re: Luftdaten
Posted: Wednesday 12 August 2020 14:24
by svde
WvdM78 wrote: Wednesday 12 August 2020 12:56
I am trying to add a luftdaten sensor near my street (not my own) in domoticz via public url.
It's only meant to work with your own luftdaten sensor. A different script will need to be written for your idea.
Re: Luftdaten
Posted: Wednesday 12 August 2020 20:27
by WvdM78
svde wrote: Wednesday 12 August 2020 14:24
WvdM78 wrote: Wednesday 12 August 2020 12:56
I am trying to add a luftdaten sensor near my street (not my own) in domoticz via public url.
It's only meant to work with your own luftdaten sensor. A different script will need to be written for your idea.
Thanks for your reply. I have some Json / Rest api experience but not much, I'll try. If I get something working I'll share it here.
Re: Luftdaten
Posted: Tuesday 18 August 2020 16:14
by Stimpy68
Hi, I have a problem when the sensor doesn't have any data, domoticz reports this with a very high spike and that messes up al the history stats (2.5PPM always reports a 32 value in domoticz).

- Aantekening 2020-08-18 160208.png (17.49 KiB) Viewed 9815 times

- Aantekening 2020-08-18 161002.png (51.29 KiB) Viewed 9815 times

- Aantekening 2020-08-18 161031.png (15.38 KiB) Viewed 9815 times
Don't have a clue why once or twice a day the sensor has no data at all (no reboots occured, it is the same as rebooting the sensor, it takes about 2 minutes before the first values are measured, when the script calls for the valuas it gets "-" And the log says:
Code: Select all
2020-08-18 15:58:00.321 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Luftdaten
2020-08-18 15:58:00.321 Error: dzVents: Error: (3.0.2) /domoticz/scripts/dzVents/generated_scripts/Luftdaten.lua:25: attempt to index a nil value (field '?')
2020-08-18 16:02:00.407 Error: dzVents: Error: (3.0.2) An error occurred when calling event handler Luftdaten
2020-08-18 16:02:00.407 Error: dzVents: Error: (3.0.2) /domoticz/scripts/dzVents/generated_scripts/Luftdaten.lua:25: attempt to index a nil value (field '?')
Is there anyway to let the script ignore the fact that there is no data/value?
Re: Luftdaten
Posted: Tuesday 18 August 2020 17:39
by waaren
Stimpy68 wrote: Tuesday 18 August 2020 16:14
Hi, I have a problem when the sensor doesn't have any data, domoticz reports this with a very high spike and that messes up al the history stats (2.5PPM always reports a 32 value in domoticz).
Is there anyway to let the script ignore the fact that there is no data/value?
There are different versions of the script in use. If you share the version you have in use now, I will have a look.
Re: Luftdaten
Posted: Wednesday 19 August 2020 6:09
by Stimpy68
waaren wrote: Tuesday 18 August 2020 17:39
There are different versions of the script in use. If you share the version you have in use now, I will have a look.
Thanks! I only have the SDS011, no other sensors on it. Here is the one I use:
Code: Select all
local FQDN = '192.168.0.85'
return {
active = true,
on = {
timer = { 'every minute' },
httpResponses = { 'luftdatenRetrieved' } -- matches callback string below
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'http://' .. FQDN .. '/data.json',
method = 'GET',
callback = 'luftdatenRetrieved'
})
elseif (item.isHTTPResponse) then
if (item.ok and item.isJSON) then -- statusCode == 2xx
if tonumber(item.json.age) < 60 then
-- 1: SDS_P1 PM10, 2: SDS_P2 PM2.5, 3: DHT22 temp, 4: DHT22 hum, 5: BME280 temp, 6: BME280 baro, 7: BME280 hum
domoticz.devices('Fijn stof PM10').updateCustomSensor(item.json.sensordatavalues[1].value)
domoticz.devices('Fijn stof PM2.5').updateCustomSensor(item.json.sensordatavalues[2].value)
-- domoticz.devices('Luftdaten DHT22').updateTempHum(item.json.sensordatavalues[3].value,item.json.sensordatavalues[4].value,0)
if (tonumber (item.json.sensordatavalues[5].value) < 100) and (tonumber (item.json.sensordatavalues[6].value) < 105000) then
-- domoticz.devices('Luftdaten BME280').updateTempHumBaro(item.json.sensordatavalues[5].value,item.json.sensordatavalues[7].value,0,(item.json.sensordatavalues[6].value/100),0)
end
end
else
-- oops
domoticz.log('Error fetching Luftdaten data', domoticz.LOG_ERROR)
domoticz.log(item.data, domoticz.LOG_ERROR)
end
end
end
}
Re: Luftdaten
Posted: Wednesday 19 August 2020 9:04
by waaren
Stimpy68 wrote: Wednesday 19 August 2020 6:09
Here is the one I use:
Can you try with this?
Code: Select all
local FQDN = '192.168.0.85'
return {
active = true,
on = {
timer = { 'every minute' },
httpResponses = { 'luftdatenRetrieved' } -- matches callback string below
},
execute = function(domoticz, item)
if (item.isTimer) then
domoticz.openURL({
url = 'http://' .. FQDN .. '/data.json',
method = 'GET',
callback = 'luftdatenRetrieved'
})
elseif (item.isHTTPResponse) then
if (item.ok and item.isJSON) then -- statusCode == 2xx
if tonumber(item.json.age) < 60 then
-- 1: SDS_P1 PM10, 2: SDS_P2 PM2.5, 3: DHT22 temp, 4: DHT22 hum, 5: BME280 temp, 6: BME280 baro, 7: BME280 hum
domoticz.log(item.json,domoticz.LOG_FORCE)
domoticz.devices('Fijn stof PM10').updateCustomSensor(item.json.sensordatavalues[1].value)
domoticz.devices('Fijn stof PM2.5').updateCustomSensor(item.json.sensordatavalues[2].value)
-- domoticz.devices('Luftdaten DHT22').updateTempHum(item.json.sensordatavalues[3].value,item.json.sensordatavalues[4].value,0)
if item.json.sensordatavalues[5] and item.json.sensordatavalues[6] and item.json.sensordatavalues[6].value and item.json.sensordatavalues[6].value then
if ( ( tonumber (item.json.sensordatavalues[5].value) or 100 ) < 100) and ( (tonumber (item.json.sensordatavalues[6].value) or 105000 ) < 105000) then
-- domoticz.devices('Luftdaten BME280').updateTempHumBaro(item.json.sensordatavalues[5].value,
item.json.sensordatavalues[7].value,0,(item.json.sensordatavalues[6].value/100),0)
end
end
end
else
-- oops
domoticz.log('Error fetching Luftdaten data', domoticz.LOG_ERROR)
domoticz.log(item.data, domoticz.LOG_ERROR)
end
end
end
}