I setup a custom device in Hubitat to make it easy to pass basic information back and forth between Homeseer. I got the device driver from the guys at sharptools. I will add it at the end in case anyone else wants to use it. The idea is that I can setup devices to pass information back and forth easily that are note related to a particular device. The example below is for keeping track of the number of people home as tracked in Homeseer through mobile phone location.
The plugin has a hard time understanding the deice, for obvious reasons, so Would it be possible to add this as a supported device? Thanks.
This is what I see in Homeseer:
View of device in Hubitat.
Here is what maker shows:
{"name":"Homeseer - People Home","label":"Homeseer - People Home","type":"Virtual Values","id":"846","date":"2020-12-25T12:51:00+0000","model":null,"manufacturer":null,"capabili ties":["Actuator","Notification","SwitchLevel","Switch","Sensor","S peechSynthesis"],"attributes":{"switch":"on","dataType":"NUMBER","values":nu ll,"text":"Here is the text","level":"100","number":"99"},"commands":[{"command":"deviceNotification"},{"command":"setNumber"},{"c ommand":"setLevel"},{"command":"speak"},{"command":"setText" },{"command":"off"},{"command":"on"}]}
Driver code:
The plugin has a hard time understanding the deice, for obvious reasons, so Would it be possible to add this as a supported device? Thanks.
This is what I see in Homeseer:
View of device in Hubitat.
Here is what maker shows:
{"name":"Homeseer - People Home","label":"Homeseer - People Home","type":"Virtual Values","id":"846","date":"2020-12-25T12:51:00+0000","model":null,"manufacturer":null,"capabili ties":["Actuator","Notification","SwitchLevel","Switch","Sensor","S peechSynthesis"],"attributes":{"switch":"on","dataType":"NUMBER","values":nu ll,"text":"Here is the text","level":"100","number":"99"},"commands":[{"command":"deviceNotification"},{"command":"setNumber"},{"c ommand":"setLevel"},{"command":"speak"},{"command":"setText" },{"command":"off"},{"command":"on"}]}
Driver code:
Code:
/* Virtual Values Author: @josh (SharpTools.io) Description: The Virtual Values device driver exposes a variety of methods which can be used to set values of specific attributes. These attributes can then be used in other Apps within Hubitat or in SharpTools.io Dashboards by using Hero Attribute tiles. This serves as a flexible 'utility' device for setting arbitrary values that you want to use elsewhere. Command to Attribute Mappings setText → text speak → text *1 deviceNotification → text *2 setNumber → number setLevel → level, [switch] *3 on → switch off → switch *1 speak() is a wrapper method for setText to provide compatibility with apps that support Speech Synthesis devices *2 deviceNotification() is a wrapper method for setText to provide compatibility with apps that support Notify devices *3 setLevel will issue the off() command if the level is set to 0 and will leave the level set at the previous value Other Notes: The on/off commands are useful for reflecting an active/default state in SharpTools.io dashboards which is helpful for setting the color of your tile based on the device's state. */ metadata { definition (name: "Virtual Values", namespace: "sharptools-io", author: "Josh Lyon") { capability "Actuator" capability "Sensor" capability "Switch" capability "Switch Level" capability "Notification" capability "Speech Synthesis" command "setText", ["STRING"] command "setNumber", ["NUMBER"] attribute "text", "STRING" attribute "number", "NUMBER" } preferences {} } def parse(String description) { } def on() { log.trace "Executing 'on'" turnOn() } def off() { log.trace "Executing 'off'" turnOff() } def setNumber(value){ log.trace "Executing setNumber $value" Map numberEvent = buildEvent("number", value, null) sendEvent(numberEvent) } def setText(value){ log.trace "Executing setText $value" Map event = buildEvent("text", value, null) sendEvent(event) } /* Also map speak() and deviceNotification() to setText for convenience */ def speak(value){ setText(value) } def deviceNotification(value){ setText(value) } private Map buildEvent(name, value, unit=null) { Map eventMap = [name: name, value: value, unit: unit, isStateChange: true] return eventMap } /*----- Set Level ---- */ def setLevel(value) { log.trace "Executing setLevel $value" def intValue = value as Integer def newLevel = Math.max(Math.min(intValue, 100), 0) Map levelEventMap = buildEvent("level", newLevel, "%") if (levelEventMap.value == 0) { turnOff() // notice that we don't set the level to 0' } else { implicitOn() sendEvent(levelEventMap) } } def setLevel(value, duration) { log.trace "Executing setLevel $value (ignoring duration)" setLevel(value) } private implicitOn() { if (device.currentValue("switch") != "on") { turnOn() } } private turnOn() { sendEvent(name: "switch", value: "on", isStateChange: true) } private turnOff() { sendEvent(name: "switch", value: "off", isStateChange: true) } def installed() { setLevel(100) setText("Use setText to set me") setNumber(100) }
Comment