more G-Labs products

Author Topic: Removing or Clearing a Property  (Read 931 times)

January 16, 2016, 08:41:11 PM
Read 931 times

Deggle

  • *
  • Information
  • Newbie
  • Posts: 11
Hello,

I'm reading data from some wireless temperature sensors (Oregon THGR810s via RFXCom) and along with the readings they give a simple (one bit) battery flag which essentially just shows when the battery is 'Low'.

So, if my code sees this flag, I set the battery level to 10 which then displays a little red low battery using the standard sensor widget:

Program.RaiseEvent(module, "Status.Battery", "10", "Low Battery");

That's great - but the problem is this...

If the battery is replaced, one option is to simply update this to 100% (and I could update the widget to hide this) however this isn't really ideal as all I know form the data is if the battery is low or not (so 100% may be misleading). Ideally I'd like to 'clear' the property altogether so the widget just doesn't see it anymore.

I've tried setting the value to null but that didn't work.

Just wondered if I'd missed something?

My next option is to add a 'LowBattery' 0/1 property, and update the widget to show this. This is fine and I'm happy to go that way, but I thought I'd check the if removal of a property was possible first.

Thanks for your help!

T

January 17, 2016, 01:26:55 AM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I don't know how to delete a parameter via code, but you can manually delete the parameter from the config menu.  Go to the "Configure->Groups" and select the correct location where your sensor is located.  Select the triple line on the right side and scroll to locate the parameter.  Select it, click "Delete", and it'll be removed from the widget.  If you really only do this once a year, it might be easier to just manually delete the property.  If there's a coded way to do it, that would be great too.

January 17, 2016, 06:15:59 PM
Reply #2

Deggle

  • *
  • Information
  • Newbie
  • Posts: 11
Thanks for the tip - that's great. I have some of these sensors which haven't had new batteries in for about 4 years and still aren't reporting as low, so it's certainly not too much trouble to do this manually.

I do think it may be good if raising an event setting to null were to remove it (as opposed to setting it to an empty string) however I understand that something like this which seems like a small change could end up breaking other code.