Water Level Sensor Capability


(Nick Baker) #1

Hi Guys

Any idea what the best capability would be to report a level from a sensor? Specifically a water level in a tank? I want to report as a percentage to full but cant see any sensor level capabilities. All I can see is Switch Level which seems to be for devices controlling the level of something (dimmer, volume, speed etc).

Any ideas?

Nick


(Jimmy) #2

i don’t think i’ve seen any z-wave or zigbee sensor with this capability


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #3

SmartThings is slow to add new Capabilities, and they “never” consult the Community for ideas or feedback on them. Reference the Category:


So…

You have 2 choices.

  1. Just use Capability “Sensor” and add arbitrary Attribute(s)

  2. Or use any Capability that has a numeric value for a sensor (e.g., Temperature, Switch Level, Power, …).

I strongly recommend approach #2, because then your DTH will be instantly compatible with SmartApps that react to that Capability as an input.

e.g., If there is a SmartApp that “alert me when it is too hot”, then writing your Water Level to Temperature will immediately be able to use that SmartApp!

(And apps like ActionTiles will be able to display your Water Level on a Temperature Tile).


(Nick Baker) #4

Hi Jimmy

I am making my own LAN connected device to report the value, but just need the best way to record it in ST. I can quite happily use an attribute and custom commands to handle the data but thought there might be a more ‘standard’ way.

Nick


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #5

It’s not so much that there is a “standard”, as there is a lack of standards.

  • The only way you can be certain your DTH will work with existing SmartApps is if you use one of the existing Capabilities.

  • It is also acceptable to do it both at the same time. e.g., create an ad hoc Attribute “waterLevel” while also writing the same value to Attribute “temperature” (and claiming Capability “temperature measurement”). For devices that don’t emit a lot of events, the overhead is trivial.


(Matthew McDermott) #6

Just curious, if he chose Switch Level, which is read write, can he override it and make it read only? Or would his Setter just throw a silent exception?


(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy) #7

Technically, SmartThings’s “Device Instance Objects” don’t have setter methods; instead, they offer Commands which may have the side effect of changing the values of Attributes.

If a DTH claims Capability “Switch Level”, then it should / must offer the setLevel() Command.

There’s no contract that the Command must perform any function successfully. I think it would be safest to fail silently, or post a warning to Live Logging; but a more severe Error is likely unnecessary.

If you don’t provide at least a stub Command, then you risk App and SmartApp exceptions with possibly serious implications, such as crashing (since such apps may not have been written with clean exception trapping).