This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.

The Homey Community has been moved to https://community.athom.com.

This forum is now read-only for archive purposes.

Detecting Null variable

vaderagvaderag Member
edited March 2018 in Questions & Help
I have a particular Z-wave PIR that occasionally (yet frequently) decides not to report luminance

I have a flow that uses this luminance, however obviously if there is no value it does not activate. I would like this to activate when luminance is 'null'

I have tested outputting the value to my phone and it receives the string 'null', although the display next to the tag in Homey is '-'

I have tried setting up a logic variable as an OR command for #Luminance = null (and every card variant of it that i can) and also tried with the - but neither seem to activate 

Can anyone advise how I can use this value?
Thanks!

Edit: I've even noticed that the Battery alarm is also reporting null when this issue occurs, so tried the following and still no dice...

Comments

  • Using tags in normal logic cards is still not possible as far as i know. There are GH issues for it.
  • Using tags in normal logic cards is still not possible as far as i know. There are GH issues for it.
    I use them elsewhere successfully...
    E.g if luminance < 30
  • Ok. GH issues can be closed then.
  • Ok. GH issues can be closed then.
    Well, they're clearly not perfect given my initial post, but I do have multiple flows successful in using a tag in a logic card...

    If we could establish the string / value for null I'm sure it could work. 
    I think part of the problem however may be that it's a number value tag and I'm trying to match it to the string which is reported
  • But is actualy a workaround for missing values in the devices?
    If value fails then do something?
    Maybe best to open a GH issue then for adding the -

  • But is actualy a workaround for missing values in the devices?
    If value fails then do something?
    Maybe best to open a GH issue then for adding the -

    Can't find a workaround... :(
  • I guess Athom filters out the 'null' variables to prevent unexpected behavior and this is best for most new Homey users. 

    I think if we tell @Kees de Vries that the temperature is null he will call for Rayonhoofden  as he doesn't know the difference with the Temperature of 0  ;-) 

    If you really want to know it is possible using an one-liner in Homeyscript. 
    I tested two numeric  Tags from which one is a 'null'



    Paste below  in a new script ( testForNull.js ) 
    // testForNull.js Test first argument if it is 'null' 
    if ( args[0] === 'null' ) { log("Argument is null");return true} else { log("Argument is Not null"); return false};

    And drop the tag in the "Run a Script with an argument" but remove the spaces around the tag!

    Keeping the Homeyscript open shows the result  when testing. 
  • @GeurtDijker
    Thanks so much for the script - worked a treat (once I'd worked out how to actually add a HomeyScript!!

Sign In or Register to comment.