Ikea vindriktning air quality sensor
Moderator: leecollings
-
- Posts: 6
- Joined: Tuesday 10 August 2021 18:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Ikea vindriktning air quality sensor
Hi all,
I took the idea of the Ikea vindriktning air quality sensor hack for home assistant and modified the code significantly to make it suitable to use with Domoticz. For those interested, please visit my github repository: https://github.com/marceldbo/VINDRIKTNI ... T-Domoticz
Since I use a Wemos D1 Mini, there are also pins enough to add other sensors e.g. BME/BMP280, DS18B20.
Enjoy and feel free to comment.
I took the idea of the Ikea vindriktning air quality sensor hack for home assistant and modified the code significantly to make it suitable to use with Domoticz. For those interested, please visit my github repository: https://github.com/marceldbo/VINDRIKTNI ... T-Domoticz
Since I use a Wemos D1 Mini, there are also pins enough to add other sensors e.g. BME/BMP280, DS18B20.
Enjoy and feel free to comment.
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Ikea vindriktning air quality sensor
Perhaps also use the Alert Sensor Device to give an colored indication of the Air quality? https://www.domoticz.com/wiki/Domoticz_ ... ert_sensor
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 6
- Joined: Tuesday 10 August 2021 18:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Ikea vindriktning air quality sensor
Interesting idea, indeed. I will have a look.
-
- Posts: 18
- Joined: Wednesday 07 April 2021 19:33
- Target OS: Linux
- Domoticz version: 2023.2
- Location: Belgium
- Contact:
Re: Ikea vindriktning air quality sensor
Nice work simplifying the original code. Whilst elegant, it was kind of hard to read and included a lot of useless stuff for us, Domoticz users. I intended to do the same as you did but you were faster
I still haven't visited my local Ikea to acquire the sensor but I'm already playing with the code.
I moved the config variables (ssid, password, ... ) to the Config.h tab and added a var for the Domoticz idx.
I also replaced Pubsubclient with ArduinoMqttClient/ArduinoJson but that's just a personal choice, the functionality is the same.
I noticed that you're updating the svalue but Domoticz is expecting the ppm value to be in the nvalue. Well, that's the way it works on my setup anyway (I temporarily hard-coded a value in the nvalue field for testing).
I still haven't visited my local Ikea to acquire the sensor but I'm already playing with the code.
I moved the config variables (ssid, password, ... ) to the Config.h tab and added a var for the Domoticz idx.
I also replaced Pubsubclient with ArduinoMqttClient/ArduinoJson but that's just a personal choice, the functionality is the same.
I noticed that you're updating the svalue but Domoticz is expecting the ppm value to be in the nvalue. Well, that's the way it works on my setup anyway (I temporarily hard-coded a value in the nvalue field for testing).
-
- Posts: 6
- Joined: Tuesday 10 August 2021 18:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Ikea vindriktning air quality sensor
Moving the config variables to the config file was indeed also on my todo list . The Ikea sensor provides values in ug/m3 and not ppm, because it is a generic sensor, measuring particles in the air at intervals. Ppm is typically used for specific sensors which measure the concentration of one type of gas with a specific weight, hence you can easily calculate the ppm. Converting the ug/m3 to ppm in case of the Ikea type of sensor is most likely going to provide you with unreliable values, as you would need to know the presence and percentage/concentration of each gas in your area and calculate the values accordingly.
The ArduinoMqttClient/ArduinoJson route is certainly a more elegant way of building the MQTT message. My solution was based on code I had already done for a different sensor
By the way, I use a custom sensor in Domoticz so the svalue works fine. What sensor type are you using for your device?
The ArduinoMqttClient/ArduinoJson route is certainly a more elegant way of building the MQTT message. My solution was based on code I had already done for a different sensor
By the way, I use a custom sensor in Domoticz so the svalue works fine. What sensor type are you using for your device?
-
- Posts: 18
- Joined: Wednesday 07 April 2021 19:33
- Target OS: Linux
- Domoticz version: 2023.2
- Location: Belgium
- Contact:
Re: Ikea vindriktning air quality sensor
I wasn't aware of that, thanks for the explanation !
Same for me I already had written the MQTT code for other devices.
I used the Air Quality sensor
-
- Posts: 58
- Joined: Wednesday 18 April 2018 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Deutschland
- Contact:
Re: Ikea vindriktning air quality sensor
I have set up the Sensot with a 8622 D1 mini
all looks fine but I allways get a 0 Zero in the submitted Data.
Any Idea why?
I used Air Quality sensor
should I try with a Custom Sensor instead?
...
tried with Custom Senso, also Zero
It communicates but allways deliver a 0 in Data
all looks fine but I allways get a 0 Zero in the submitted Data.
Any Idea why?
I used Air Quality sensor
should I try with a Custom Sensor instead?
...
tried with Custom Senso, also Zero
It communicates but allways deliver a 0 in Data
________________________________________________________________________
global chief of permanent lightning and strike detonator
global chief of permanent lightning and strike detonator
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Ikea vindriktning air quality sensor
Do you send the correct data to Domoticz (nValue, sValue), see https://www.domoticz.com/wiki/Domoticz_ ... .2Fsensors for more information. MQTT uses the same definition as the API/Json calls.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 536
- Joined: Friday 23 December 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: Netherlands Purmerend
- Contact:
Re: Ikea vindriktning air quality sensor
Anybody intrested to work with me to get this one in Tasmota or ESPeasy ?
-
- Posts: 58
- Joined: Wednesday 18 April 2018 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Deutschland
- Contact:
Re: Ikea vindriktning air quality sensor
it send s {"idx":20373,"nvalue":0,"svalue":"0.00"}
I don´t know why?
I don´t know why?
________________________________________________________________________
global chief of permanent lightning and strike detonator
global chief of permanent lightning and strike detonator
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Ikea vindriktning air quality sensor
Then something is not right on your 8622 D1 mini code or hardware.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 18
- Joined: Wednesday 07 April 2021 19:33
- Target OS: Linux
- Domoticz version: 2023.2
- Location: Belgium
- Contact:
Re: Ikea vindriktning air quality sensor
Check your log in Domoticz. Does it says something along the lines "Invalid data received!" ?
I've got that error when setting up a MQ-7 sensor with an Air Quality sensor in Domoticz. Turns out Domoticz didn't want decimal in the JSON input, solved it by rounding the sensor data (or transform it into an int).
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Ikea vindriktning air quality sensor
Well the complaint was that 0 was seen in Domoticz. And now 0 was send. So if someone want to see the real value (eg 50) then you have to send 50
And the nvalue and svalue are important. For an Airquality sensor you only send PPM as nvalue
For a custom sensor you have to send nvalue:0 and svalue:SENSORVALUE.
See wiki page https://www.domoticz.com/wiki/Domoticz_ ... .2Fsensors
And the nvalue and svalue are important. For an Airquality sensor you only send PPM as nvalue
For a custom sensor you have to send nvalue:0 and svalue:SENSORVALUE.
See wiki page https://www.domoticz.com/wiki/Domoticz_ ... .2Fsensors
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 58
- Joined: Wednesday 18 April 2018 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Deutschland
- Contact:
Re: Ikea vindriktning air quality sensor
Thank you all for your help, I found MY Error!
I used PIN D3 instead of D2, so there was no Data delivered.
Looked and checked x Times and did not see it
Connect correctly, and yeah, it works, Great
I used PIN D3 instead of D2, so there was no Data delivered.
Looked and checked x Times and did not see it
Connect correctly, and yeah, it works, Great
________________________________________________________________________
global chief of permanent lightning and strike detonator
global chief of permanent lightning and strike detonator
-
- Posts: 58
- Joined: Wednesday 18 April 2018 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Deutschland
- Contact:
Re: Ikea vindriktning air quality sensor
Now, I like have a virtual switch showing the Status like a traffic light.
0-35 green
36-85 yellow
86 - ... red
I can´t find any virtual Device, that can help here.
Anyone with an Idea?
I like to Script something that will change the Switch Status.
0-35 green
36-85 yellow
86 - ... red
I can´t find any virtual Device, that can help here.
Anyone with an Idea?
I like to Script something that will change the Switch Status.
________________________________________________________________________
global chief of permanent lightning and strike detonator
global chief of permanent lightning and strike detonator
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Ikea vindriktning air quality sensor
As mentioned before: Try the Alert Sensor
It is 5 levels: Grey, Green, Yellow, Orange, Red
You can add text to indicate the status
https://www.domoticz.com/wiki/Domoticz_ ... ert_sensor
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 58
- Joined: Wednesday 18 April 2018 13:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Deutschland
- Contact:
Re: Ikea vindriktning air quality sensor
Great.
right now I´m still struggling with the dzvents Scripts reading and using the Sensor Data.
Whatever i try I got back that try to compare Nil with Number
If the Base Script works, I may need to send this to my new Alert Sensor:
/json.htm?type=command¶m=udevice&idx=20378&nvalue=1&svalue=gering%20keine%20besonderen%20Maßnahmen%20nötig
right now I´m still struggling with the dzvents Scripts reading and using the Sensor Data.
Whatever i try I got back that try to compare Nil with Number
Code: Select all
return {
active = true,
on = { devices = { 'Feinstaubsensor EG','Feinstaubsensor Aussen','FSB'}},
execute = function(domoticz, device, email)
if tonumber(domoticz.devices('Feinstaubsensor EG').State) <= 35 then domoticz.devices('FSB').dimTo(0)
elseif tonumber(domoticz.devices('Feinstaubsensor EG').State) > 36 < 85 then domoticz.devices('FSB').dimTo(10)
elseif tonumber(domoticz.devices('Feinstaubsensor EG').State) >= 86 then domoticz.devices('FSB').dimTo(20)
end
end
}
Code: Select all
2021-08-20 15:17:51.074 Status: dzVents: Info: Handling events for: "Feinstaubsensor EG", value: "14.00"
2021-08-20 15:17:51.074 Status: dzVents: Info: ------ Start internal script: FSBTest: Device: "Feinstaubsensor EG (MQTTSonoffServer)", Index: 20375
2021-08-20 15:17:51.074 Status: dzVents: Info: ------ Finished FSBTest
2021-08-20 15:17:51.074 Error: dzVents: Error: (3.1.7) An error occurred when calling event handler FSBTest
2021-08-20 15:17:51.074 Error: dzVents: Error: (3.1.7) ...i/domoticz/scripts/dzVents/generated_scripts/FSBTest.lua:8: attempt to compare nil with number
/json.htm?type=command¶m=udevice&idx=20378&nvalue=1&svalue=gering%20keine%20besonderen%20Maßnahmen%20nötig
________________________________________________________________________
global chief of permanent lightning and strike detonator
global chief of permanent lightning and strike detonator
- waltervl
- Posts: 5148
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Ikea vindriktning air quality sensor
Why do you do that in dzVents?
You can do this directly from the code on the Wemos/Arduino/8622 D1 mini etc.
So have the code send the MQTT message for the custom sensor and have the code send an MQTT message for the alert sensor
Should be something like
{"idx":4095,"nvalue":0,"svalue":"90.00"} -- Custom sensor with value = 90.00
{"idx":201,"nvalue":"4","svalue":"Value 90 - Bad Air Quality"} -- Alert Sensor Red sign with text: "Value 90 - Bad Air Quality"
You can do this directly from the code on the Wemos/Arduino/8622 D1 mini etc.
So have the code send the MQTT message for the custom sensor and have the code send an MQTT message for the alert sensor
Should be something like
{"idx":4095,"nvalue":0,"svalue":"90.00"} -- Custom sensor with value = 90.00
{"idx":201,"nvalue":"4","svalue":"Value 90 - Bad Air Quality"} -- Alert Sensor Red sign with text: "Value 90 - Bad Air Quality"
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest