Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
PowerHome Bug Reports
 PowerHome Messageboard : PowerHome Bug Reports
Subject Topic: Minor Bug/SDocumentation Issue Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
smarty
Super User
Super User
Avatar

Joined: May 21 2006
Location: United States
Online Status: Offline
Posts: 728
Posted: November 24 2013 at 09:34 | IP Logged Quote smarty

I was doing some macro clean-up/optimization when I stumbled across this...

The PH command "ph_getinsteonstat()" should return a "0", "1", or "2" per the help documentation.

It appears to me that in cases were the status is unknown, the "0" is NEVER RETURNED. In the formula below, I check for all possible states, but I can't make an "Unknown" result - even when I scramble the {Room Device ID} to gibberish.

.............................

if(ph_getinsteonstat("{ROOM DEVICE ID}")=1,"Off",if(ph_getinsteonstat("{ROOM DEVICE ID}")=2,"On","Unknown"))

__________________
Elk - Insteon - BlueIris - DMC1 - PowerHome - XLobby - HA_Bridge w/Dots - Brultech
Back to Top View smarty's Profile Search for other posts by smarty
 
dhoward
Admin Group
Admin Group
Avatar

Joined: June 29 2001
Location: United States
Online Status: Offline
Posts: 4447
Posted: November 26 2013 at 21:27 | IP Logged Quote dhoward

Smarty,

I checked the code for this function and its rather simplistic. It doesn't check for the existence of the actual device ID. It merely pulls the "Status" field from the Insteon devices table and interprets the result. In the case of an ID that doesn't actually exist, the select actually fails (this is not checked for) and the result is a default of 0 which will cause the function to return a 1. The only way a 0 will be returned is if the Status value is -1 which is the default when a device is first created.

I'll rewrite this function to include error handling and make it a bit more robust.

Dave.
Back to Top View dhoward's Profile Search for other posts by dhoward Visit dhoward's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum