Ikea vindriktning air quality sensor

Moderator: leecollings

redhouse
Posts: 6
Joined: Tuesday 10 August 2021 18:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Ikea vindriktning air quality sensor

Post by redhouse »

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.
User avatar
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

Post by waltervl »

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
redhouse
Posts: 6
Joined: Tuesday 10 August 2021 18:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea vindriktning air quality sensor

Post by redhouse »

Interesting idea, indeed. I will have a look.
Jieffe
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

Post by Jieffe »

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).
redhouse
Posts: 6
Joined: Tuesday 10 August 2021 18:02
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Ikea vindriktning air quality sensor

Post by redhouse »

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?
Jieffe
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

Post by Jieffe »

redhouse wrote: Friday 13 August 2021 12:56 The Ikea sensor provides values in ug/m3 and not ppm, because it is a generic sensor, measuring particles in the air at intervals.
I wasn't aware of that, thanks for the explanation !
redhouse wrote: Friday 13 August 2021 12:56 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 ;)
Same for me :) I already had written the MQTT code for other devices.
redhouse wrote: Friday 13 August 2021 12:56 By the way, I use a custom sensor in Domoticz so the svalue works fine. What sensor type are you using for your device?
I used the Air Quality sensor
mastadook
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

Post by mastadook »

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
________________________________________________________________________
global chief of permanent lightning and strike detonator
User avatar
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

Post by waltervl »

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
freijn
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

Post by freijn »

mastadook wrote: Thursday 19 August 2021 11:39
Any Idea why?
I used Air Quality sensor
should I try with a Custom Sensor instead?
Yeah, to a custom sensor it works perfectly.
freijn
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

Post by freijn »

Anybody intrested to work with me to get this one in Tasmota or ESPeasy ?
mastadook
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

Post by mastadook »

it send s {"idx":20373,"nvalue":0,"svalue":"0.00"}
I don´t know why?
________________________________________________________________________
global chief of permanent lightning and strike detonator
User avatar
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

Post by waltervl »

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
Jieffe
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

Post by Jieffe »

mastadook wrote: Thursday 19 August 2021 12:14 it send s {"idx":20373,"nvalue":0,"svalue":"0.00"}
I don´t know why?
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).
User avatar
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

Post by waltervl »

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
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
freijn
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

Post by freijn »

mastadook wrote: Thursday 19 August 2021 12:14 it send s {"idx":20373,"nvalue":0,"svalue":"0.00"}
I don´t know why?
in = {"idx":4095,"nvalue":0,"svalue":"13.00"} is my datagram

What hardware (wemos, ESP ? ) are you using and on what pin have you connected the TX line coming from the sensor?
mastadook
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

Post by mastadook »

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 :oops:

Connect correctly, and yeah, it works, Great :)
________________________________________________________________________
global chief of permanent lightning and strike detonator
mastadook
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

Post by mastadook »

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.
________________________________________________________________________
global chief of permanent lightning and strike detonator
User avatar
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

Post by waltervl »

mastadook wrote: Friday 20 August 2021 13:17 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.
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

Image
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
mastadook
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

Post by mastadook »

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

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
If the Base Script works, I may need to send this to my new Alert Sensor:
/json.htm?type=command&param=udevice&idx=20378&nvalue=1&svalue=gering%20keine%20besonderen%20Maßnahmen%20nötig
________________________________________________________________________
global chief of permanent lightning and strike detonator
User avatar
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

Post by waltervl »

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"
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest