IKEA VINDSTYRKA Zigbee Air quality sensor

Thanks! This really helped me. I just have one problem. The values are being recorded as strings, rather than integers. Do you know where I would need to change this?

Here is how my history looks like because of this:

image

this should make the sensor value an int.

customize:
  sensor.air_monitor_voc_index:
    state_class: measurement
    device_class: aqi

Thanks for the reply. Apologies for the ignorance, but where do I need to add this?
Later Edit:
I have tried to add the customization that @diplix suggested, but the issue persisted. However, it is not fixed after I have made the change directly in the GUI. Thanks!

Hi Ben,

Can you describe in detail how to achieve this? Which command line tool did you use to patch ZHA toolkit?

One of the easiest ways is to install the Visual Studio Code Server addon in HA.
Via the Studio Code Server addon you will be able to directly edit/change the relevant ZHA Toolkit files.

1 Like

I just got an update for ZHA Toolkit and did not need the file change to zha_toolkit/zcl_attr.py. I still needed the helper to create the sensor.

1 Like

I feel a bit lost
Here is what I did:

  1. The code in zha_toolkit/zcl_attr.py is already like you wrote. So need to change

  2. no need

  3. created the automation, when ran it creates entity sensor.air_monitor_voc_index and I see it’s value

  4. Then when creating the helper I expected to see in the preview the value(50), instead I see the string

When I do select the device I do see the zigbee device template is matched, but the data is no present

What I’m doing wrong?

The code was already fixed because there was a new version of ZHA Toolkit.

I have set the template to {{ None }} instead of air_monitor_voc_index, then you shouldn’t have such an issue with the diagram not showing as a graph.

You also need to run the automation in regular intervals to update the template sensor.

What do you mean have set the template to 0 ?

Automation runs every hour to update the data, but for testing I do run actions every now and then

Problem is data is available in entity, but can not make it visible in the template :frowning:

You should put no text in the template sensor where you wrote air_monitor_voc_index.
I use the template {{ None }} which seems to work well

You do not see the value in the preview because it needs to written manually to the template sensor by the automation. There the state_id should match up with the entity id of the template sensor you created first.

Oh my god,
I got what was wrong.
I was running the automation, which created the sensor.
and I was trying it to get this sensor data in the template
While it;s the other way around
you have to create the template first, link it to the zigbee device. get its template id and put it inside the automation to update it.

3 Likes

The yaml is for an automation, not the configuration.yaml. Unless I’ve misunderstood what you are having an issue with.

1 Like

I stumbled something on a page over here: Understanding Volatile Organic Compounds (VOCs) and TVOC Measurements

" Note: TVOC values in parts per million (ppm) are still available via Sensirion’s conversion formula: Sensors Thresholds"

This brought me nowhere, but I dug deeper and found this discussion
https://forums.adafruit.com/viewtopic.php?t=182288
and

Could there be a way to reverse-engineer or calculate even approximate tvoc as ppb from the voc index? One would have to know the starting point though?
Or should I just stick with the VOC index which Sensorion claims is way better than exact value?

I thought I would provide an update to @tinkerwidget’s good work as I had to change a few things on the latest version. You might want to skip down to the end of this post to read about what the value can actually do before setting it up.

Setting up a Relative VOC Sensor

  1. Install ‘ZHA Toolkit’ via HACS and enabled it in the configuration.yaml (read the docs)
  2. Navigate to ‘Automations & scenes’ and click ‘+ Create Automation’ followed by ‘Create new automation’
  3. Click the drop button in the top right followed by ‘Edit in YAML’ and then paste in the below noting the explanation under it. Save it when you are done.

alias: Poll - Vindstyrka VOC Sensor
description: ""
triggers:
  - minutes: /1
    trigger: time_pattern
conditions: []
actions:
  - data:
      ieee: <REPLACE ME>
      use_cache: false
      force_update: true
      endpoint: 1
      cluster: 1066
      attribute: 0
    action: zha_toolkit.attr_read
  - data:
      ieee: <REPLACE ME>
      endpoint: 1
      manf: 4476
      cluster: 64638
      attribute: 0
      state_id: sensor.vindstyrka_voc_index
      allow_create: true
    action: zha_toolkit.attr_read
  • You must replace the ieee value with the MAC address for your Vindstyrka device. This is found by navigating to you device list, clicking the Vindstyrka device and then clicking ‘Zigbee info’ within the device’s page.
  • Changing the alias or description will not effect any of the following steps so feel free
  • Leave the state_id as is. If you want to change it you will need to replace it in later steps as well.

  1. Confirm that your new sensor is working by navigating to ‘Devices & services’, selecting ‘Entities’ and searching sensor.vindstyrka_voc_index. Clicking on the entity should show a numerical value getting updated every minute.

  2. Change tab from Step 4 to ‘Helpers’, click ‘+ Create Helper’, select ‘Template’ and then ‘Template a sensor’

  3. Input the corresponding fields below into the form


Name: Relative VOC Index (24h)
State Template: {{ states('sensor.vindstyrka_voc_index') | int }}
Unit of Measurement: <Leave Blank>
Device class: Air quality index
State class: Measurement
Device: <Whatever you named your Vindstyrka>
  • You should see a preview down the bottom with a similar number to what was seen in Step 4


  1. Verify that the sensor is showing on the device. You might need to enable it.

Using the Relative VOC Index
Due to the good work in this thread from @donny007x the sensor is known to be a SEN54. What we are tapping into is Sensirion’s VOC Index which provides a 0-500 numerical value.

The summary of the hyperlinked document is that the reading is relative to a floating average of the previous 24 hours. The value 100 represents the floating average. The following is the proposed use case by Sensirion:

VOC Index Range Meaning
0-150 VOCs at or below the floating average with a buffer for small events (+50)
150-250 Trigger low remediation action.
250-400 Trigger moderate remediation action.
400-500 Trigger high remediation action.

Leaving the situation without any external influences or remediation for 24 hours will cause the value to return 100 as the floating average accounts for the additional VOCs in the room.

Basically the reading is only good for taking corrective actions (turning on fans, air purifiers and opening windows at varying intensities). You could also send an alert with the understanding of the above. Given that it was designed to integrate with Ikea Air Purifiers this makes sense.

Closing Thoughts
The sensor is built for integration into air purifiers with a focus on implementing the NOx and VOC indexes. These aren’t incredibly useful for monitoring. However, implementing readings for Raw Humidity, Raw Temperature, RAW VOC and RAW NOx from the sensor is possible at the device integration level. Ikea looks to have done this for Humidity, Temperature and NOx so it is possible they might have exposed the raw VOC in another Zigbee cluster. @donny007x seems to be the only person who had a crack at bruteforcing the endpoints so they might be able to provide more context here.

The raw VOC reading has a range of 0 - 1000 so if it exists it will likely have three attributes based on the VOC Index schema. 0 being the current value, 1 being 0 and 2 being 1000. It also might be 999 as that is what the PM2.5 bound is.

I originally had more photos for the step-by-step and a link to the raw schema but new users can only embed one image and two links.

6 Likes

The script looks promising but I get the same error:
Error: ‘Device not found: nwk=None, ieee=None’

Hi,

is it possible to control the backlight via home assistant?

Thanks in advance

2 Likes

Thank you very much, this helped :+1:

my log is flooded with this error:

This error comes from a custom integration.

Logger: custom_components.zha_toolkit.zcl_attr
Source: custom_components/zha_toolkit/zcl_attr.py:539
Integration: zha :toolbox: Toolkit (documentation, issues)
First appearance: 01:59:52 (2192 occurrences)
Last logged: 11:12:00

Result: {0: <Status.UNSUPPORTED_ATTRIBUTE: 134>} - Attribute 0 not in read ({}, {0: <Status.UNSUPPORTED_ATTRIBUTE: 134>})

Any idea how to fix this?

Awesome - Works great!

Is any of this necessary anymore? I noticed that recently I had VOC Index sensors appearing out of nowhere. They definitely were not there when I initially installed my two IKEA Vindstyrka, and I have not setup any custom sensors myself. The quirk in use for both devices is specified as “zigpy.quirks.v2.CustomDeviceV2”, is this a new quirk specifically for Vindstyrka but someone forgot to put in the proper name…?

Edit: Looks like VOC Index was added to this quirk just a week or two ago.