-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Hello
I have several Shelly Pro 4PM
I want to use the 4 inputs not connected to the relays (detached option),
I have modified your driver (adding input.GetStatus)
i did :
attribute "InputChannel", "number"
attribute "InputState", "string"
//input("channel", "number", title:"Switch", description:"0,1,2,or 3 :", defaultValue:"0" , required: true)
//Channel for input and Switch is the same
input("channel", "number", title:"Switch/Input", description:"0,1,2,or 3 :", defaultValue:"0" , required: true)
def getInputs(){
logDebug "Inputs Status called"
def params = [uri: "http://${username}:${password}@${ip}/rpc/Input.GetStatus?id=${channel}"]
try {
httpGet(params) {
resp -> resp.headers.each {
logJSON "Response: ${it.name} : ${it.value}"
}
obs = resp.data
logJSON "params: ${params}"
logJSON "response contentType: ${resp.contentType}"
logJSON "response data: ${resp.data}"
//Not necesary, InputChannel and Relaychannel are the same
state.InputChannel = obs.id
state.InputState = obs.state
//This is to update Attributes (to select in dashboard-template)
sendEvent(name: "InputChannel", value: state.InputChannel)
sendEvent(name: "InputState", value: state.InputState)
//This is to update Current States (right corner Devices page)
ison = obs.state
if (ison == true) {
sendEvent(name: "input", value: "on")
} else {
sendEvent(name: "input", value: "off")
}
} // End try
} catch (e) {
log.error "something went wrong: $e"
}
} // End Input Status
Now you can create a virtual device, in the dashboard you can select device template attributes, you can choose InputState and see the input enabled or disabled.
you have to wait 1 minute (device refresh rate)
in Rule Machine you can select Custon Attribute in Triggers Events and then Select attribute InputState, now you can use this trigger (4PM shelly input) for whatever you want.
If you want you can add all of this to your code.
thank a lot for you work.