csdozier / device-concord4

Concord 4 SmartThings Device Hander and SmartApp
9 stars 13 forks source link

Possible to have Multiple Devices? #5

Open marbaugh opened 7 years ago

marbaugh commented 7 years ago

I have been using your code now for the last few weeks and everything has been great without any issues. I am now working to integrate SmartThings with HomeAssistant following https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/

Following your directions I created a "Device" called "Alarm-Contact" in the Smarthings IDE for the Concord 4 Virtual Contact "Device Handler."

My alarm has 8 zones which all show up in the Alarm in the SmartThings App on my phone but when sending the status to the MQTT-Bridge, from the link above, no matter what zone opens the message is "smartthings/Alarm-Contact/contact = open"...so it's working but I would like to have a differnt "Device" per zone if that is possible...

Thanks for any insight or suggestions.

csdozier commented 7 years ago

You do create a device per zone. The device handler you created 'alarm-contact' is just a template. From the IDE, you add a device per zone by clicking My Devices->New Devices. Add a name and set the type to "Alarm Contact (or whatever you named it).

Then you use the smarthphone app to go to the smartapp settings of the "Concord 4 integration". You associate your device with a zone from there.

On Fri, Sep 15, 2017 at 9:26 PM, marbaugh notifications@github.com wrote:

I have been using your code now for the last few weeks and everything has been great without any issues. I am now working to integrate SmartThings with HomeAssistant following https://home-assistant.io/ blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/

Following your directions I created a "Device" called "Alarm-Contact" in the Smarthings IDE for the Concord 4 Virtual Contact "Device Handler."

My alarm has 8 zones which all show up in the Alarm in the SmartThings App on my phone but when sending the status to the MQTT-Bridge, from the link above, no matter what zone opens the message is "smartthings/Alarm-Contact/contact = open"...so it's working but I would like to have a differnt "Device" per zone if that is possible...

Thanks for any insight or suggestions.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5, or mute the thread https://github.com/notifications/unsubscribe-auth/ANJf92U0O81lHj7ztO7vbIS9YrfF00M7ks5siyPPgaJpZM4PZqVS .

marbaugh commented 7 years ago

Gotcha, I understand now. I created 8 different devices now and associated the zones to the devices in the app.

In your SmartApp all of the zones are "contactSensors." My zone 2 is a motion sensor so would this be correct?

input "zone2", "capability.motionSensor", title:"Zone 2" ?

csdozier commented 7 years ago

Looks right

On Sat, Sep 16, 2017 at 2:14 PM marbaugh notifications@github.com wrote:

Gotcha, I understand now. I created 8 different devices now and associated the zones to the devices in the app.

In your SmartApp all of the zones are "contactSensors." My zone 2 is a motion sensor so would this be correct?

input "zone2", "capability.motionSensor", title:"Zone 2" ?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5#issuecomment-329985787, or mute the thread https://github.com/notifications/unsubscribe-auth/ANJf93qqdqbX8dR6OB1DxHXNWxD55CD8ks5sjBAEgaJpZM4PZqVS .

marbaugh commented 7 years ago

I update the Concord 4 Device Handerl to have: standardTile("Zone 2", "device.zone2", width: 2, height: 2,inactiveLabel: false, decoration: "flat") { state "inactive", label: 'Foyer Motion Sensor\n', icon: "st.motion.motion.inactive", backgroundColor: "#ffffff" state "active", label: 'Foyer Motion Sensor\n', icon: "st.motion.motion.active", backgroundColor: "#00a0dc" } I also updated the Concord 4 Smart App to have: input "zone2", "capability.motionSensor", title:"Zone 2"

When I open the 'Alarm Device' in the phone app and go to Alarm --> SmartApps-->Concord 4 Integration, I see all the zones to choose from but Zone 2 now says "You Can't Currently Add This"

Here is a link of screenshots: https://photos.app.goo.gl/Hh2DBEyyx3d8RRXn2

Any thoughts or do you have any examples where a motion sensor is set up?

csdozier commented 7 years ago

It might be related to the device not changing state, try the new device handler and refresh all zones to closed... https://github.com/csdozier/device-concord4/blob/master/st-devicehandler/device-concord4.groovy

marbaugh commented 7 years ago

I tried new handler to refresh all zones to closed and in the 'Alarm Device' on the phone app everything is working but the 'Zone 3' or 'Zone4' devices I created still say open.

I also played around with the "You Can't Currently Add This" under 'Alarm Device' in the phone app and go to Alarm --> SmartApps -->Concord 4 Integration, and I noticed as soon as I change the code for the Concord 4 Integration Smart App in the IDE to input "zone2", "capability.motionSensor", title:"Zone 2" from "zone2", "capability.contactSensor" and save and "Publish for me" I see the "You Can't Currently Add This"

marbaugh commented 7 years ago

I'm going to redo the device handlers and re-set up my devices this evening I'll let you know if I have any more luck

csdozier commented 7 years ago

I made another update to the device handler. The motion sensor does not take the action 'closed', it uses 'inactive', so I made it send 'inactive' to all zones. Please update and try again.

marbaugh commented 6 years ago

I got everything up and running tonight with your updates. The refresh all zones works great.

I left your template alone and had zones 1-15 setup as contact sensors (though my zone two is a motion sensor). I created devices for all 15 zones (though I only have 1-8) and 1-8 work great, of course when I trip the motion sensor it says open.

  1. I then updated to the Concord 4 Device Handler to have: standardTile("Zone 2", "device.zone2", width: 2, height: 2,inactiveLabel: false, decoration: "flat") { state "inactive", label: 'Foyer Motion Sensor\n', icon: "st.motion.motion.inactive", backgroundColor: "#ffffff" state "active", label: 'Foyer Motion Sensor\n', icon: "st.motion.motion.active", backgroundColor: "#00a0dc" }

  2. I also updated the Concord 4 Smart App to have: input "zone2", "capability.motionSensor", title:"Zone 2"

  3. I also created a new device that uses the motionSensor device handler.

After publishing and using the mobile app, when I open the 'Alarm Device' and go to Alarm --> SmartApps-->Concord 4 Integration, I see all the zones to choose from but Zone 2 still says "You Can't Currently Add This".

I noticed again, as soon as I change the Concord 4 Smart App to say input "zone2", "capability.motionSensor", title:"Zone 2" and publish and breaks zone2. Have you been able to successfully use motionSensor instead of contactSensor in the Smart App? Is there any thing else I can do to help troubleshoot this?

marbaugh commented 6 years ago

Any thoughts?

csdozier commented 6 years ago

I’ve not had a chance to review further yet.

On Thu, Sep 21, 2017 at 8:31 PM marbaugh notifications@github.com wrote:

Any thoughts?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5#issuecomment-331317967, or mute the thread https://github.com/notifications/unsubscribe-auth/ANJf90-9fnvHX8G8vRyn-Go5pCI65elcks5skv_ggaJpZM4PZqVS .

marbaugh commented 6 years ago

Ok no problem I just had some free time tonight and figured I would reach out. Let me know if I can do anything to assist.

On Sep 21, 2017 8:32 PM, "csdozier" notifications@github.com wrote:

I’ve not had a chance to review further yet.

On Thu, Sep 21, 2017 at 8:31 PM marbaugh notifications@github.com wrote:

Any thoughts?

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5# issuecomment-331317967, or mute the thread https://github.com/notifications/unsubscribe-auth/ANJf90-9fnvHX8G8vRyn- Go5pCI65elcks5skv_ggaJpZM4PZqVS .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5#issuecomment-331318171, or mute the thread https://github.com/notifications/unsubscribe-auth/AGKAwjZaRET3sNdCfywQb2ouz05LM7Gnks5skwAwgaJpZM4PZqVS .

csdozier commented 6 years ago

I've updated the virtual motion device handler. It allows me to add a motion sensor, give it a try

https://github.com/csdozier/device-concord4/blob/master/st-devicehandler/device-concord4-virtualmotion.groovy

marbaugh commented 6 years ago

Getting much closer! Thanks for the update.

  1. The zone2 device I created in the smartings IDE shows up in the smart phone app under "my home" --> "Things" as “Active” when there is no motion and “Inactive” when there is motion.

  2. The Alarm device I created in the smarthigns IDE shows up in the smart phone app with all of the zones and allows me to select the motion sensor device created for zone 2 under the "SmartApps" ---> Concord 4 Integration. Once it's mapped the zone never changes state like all the other zones do in the Alarm device under the ‘right now tab’. But I do see under the ‘recently tab’ the following Alarm zone2 is closed or Alarm zone2 is open. Not sure if these should say active and inactive.

Also the output from the python concordsvr running is 2017-09-22 21:11:19,318 [concordsvr.py:panelMessageHandler()] - INFO - Zone 2 - 'FOYER MOTION' | State: open 2017-09-22 21:11:21,770 [concordsvr.py:panelMessageHandler()] - INFO - Zone 2 - 'FOYER MOTION' | State: closed

Not sure if these should also be ‘active’ and ‘inactive’

Let me know if screenshots would help.

marbaugh commented 6 years ago

Update:

If I changed the concord 4 device handler zone 2 (for my setup) to use open and closed instead of active and inactive and it updates in the smart phone app now.

    standardTile("Zone 2", "device.zone2",  width: 2, height: 2,inactiveLabel: false, decoration: "flat") {         
        state "closed", label: 'Foyer Motion Sensor\n', icon: "st.motion.motion.inactive", backgroundColor: "#ffffff" 
        state "open", label: 'Foyer Motion Sensor\n', icon: "st.motion.motion.active", backgroundColor: "#00a0dc"
    }  

Also I believe the virtual motion detector device handler code, the active and inactive need to be swapped to fix my issues described in the previous post where the device shows the active icon when it's really inactive.

tiles {
    standardTile("motion", "device.motion", inactiveLabel: false) {
        state "inactive", label: '${name}', icon: "st.motion.motion.inactive", backgroundColor: "#ffffff"
        state "active", label: '${name}', icon: "st.motion.motion.active", backgroundColor: "#00a0dc"
    }  

I am assuming if the python server is updated to used active and inactive for motion sensors then the "active" and "inactive" could be used in the device handler? Otherwise I think it's all working now!

csdozier commented 6 years ago

Glad to know its working. So Im now assuming open is active and updated the device handler to reflect that.

marbaugh commented 6 years ago

Ok I'll test you update today!

marbaugh commented 6 years ago

Everything is working great, I can not thank you enough for your help. What's the best way to "buy you a beer"!?

csdozier commented 6 years ago

Great! No obligation but you can buy me a beer through paypal: http://paypal.me/sdozier1

On Thu, Sep 28, 2017 at 9:17 PM, marbaugh notifications@github.com wrote:

Everything is working great, I can not thank you enough for your help. What's the best way to "buy you a beer"!?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5#issuecomment-333005052, or mute the thread https://github.com/notifications/unsubscribe-auth/ANJf94cHlvvsTAgeVWZrg5DQneWN3QYLks5snEUegaJpZM4PZqVS .

marbaugh commented 6 years ago

Sorry for the delay but just sent you a beer! Thanks again for all the help.

On Fri, Sep 29, 2017 at 10:25 AM, csdozier notifications@github.com wrote:

Great! No obligation but you can buy me a beer through paypal: http://paypal.me/sdozier1

On Thu, Sep 28, 2017 at 9:17 PM, marbaugh notifications@github.com wrote:

Everything is working great, I can not thank you enough for your help. What's the best way to "buy you a beer"!?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5# issuecomment-333005052, or mute the thread https://github.com/notifications/unsubscribe-auth/ ANJf94cHlvvsTAgeVWZrg5DQneWN3QYLks5snEUegaJpZM4PZqVS

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5#issuecomment-333140919, or mute the thread https://github.com/notifications/unsubscribe-auth/AGKAwpMxuG8WpOPNKGKci7AOa1mpUTj3ks5snP3lgaJpZM4PZqVS .

csdozier commented 6 years ago

Thanks a lot. Cheers!

On Tue, Oct 17, 2017 at 8:30 PM, marbaugh notifications@github.com wrote:

Sorry for the delay but just sent you a beer! Thanks again for all the help.

On Fri, Sep 29, 2017 at 10:25 AM, csdozier notifications@github.com wrote:

Great! No obligation but you can buy me a beer through paypal: http://paypal.me/sdozier1

On Thu, Sep 28, 2017 at 9:17 PM, marbaugh notifications@github.com wrote:

Everything is working great, I can not thank you enough for your help. What's the best way to "buy you a beer"!?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5# issuecomment-333005052, or mute the thread https://github.com/notifications/unsubscribe-auth/ ANJf94cHlvvsTAgeVWZrg5DQneWN3QYLks5snEUegaJpZM4PZqVS

.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5# issuecomment-333140919, or mute the thread https://github.com/notifications/unsubscribe-auth/ AGKAwpMxuG8WpOPNKGKci7AOa1mpUTj3ks5snP3lgaJpZM4PZqVS .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5#issuecomment-337421127, or mute the thread https://github.com/notifications/unsubscribe-auth/ANJf9w_35r0vW8qPVNw5n9-9KQWj54tXks5stUaOgaJpZM4PZqVS .

marbaugh commented 6 years ago

I am running the concordsvr and would like to be able to use the REST API from my internal network to arm/disarm the alarm. When running something like 'http://192.168.1.31:8066/concord/arm/stay' from my browser I get: TX -> 401 Unauthorized (auth key:)

Any easy way around this?

csdozier commented 6 years ago

As a small form of security to the API, its looking for a api password in a base64 encoded basic Authorization:Basic HTTP header. If you want to maintain that security, include the rest_api_password in your config file as a base64 encoded string. If you don't want to bother with that, you edit concordsvr.py at line 896 and set authorized to True.

On Sat, Nov 4, 2017 at 10:40 PM, marbaugh notifications@github.com wrote:

I am running the concordsvr and would like to be able to use the REST API from my internal network to arm/disarm the alarm. When running something like 'http://192.168.1.31:8066/concord/arm/stay' from my browser I get: TX -> 401 Unauthorized (auth key:)

Any easy way around this?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5#issuecomment-341944921, or mute the thread https://github.com/notifications/unsubscribe-auth/ANJf94O_DJ03SaN6sEhduYn0dAGYrwXKks5szSAFgaJpZM4PZqVS .

marbaugh commented 6 years ago

Could you provide an example of how to include the base64 encoded string in the REST API call 'http://192.168.1.31:8066/concord/arm/stay'

csdozier commented 6 years ago

Here is how it is done in the device handler:

def userpassascii = "admin:${concord_server_api_password}" def userpass = "Basic " + userpassascii.encodeAsBase64().toString() def hosthex = convertIPtoHex(concord_server_ip_address) def porthex = convertPortToHex(concord_server_port) log.debug("${device.deviceNetworkId}") def hubAction = new physicalgraph.device.HubAction( 'method': 'POST', 'path': "/concord${request}"+"&apiserverurl="+java.net.URLEncoder.encode(apiServerUrl("/api/smartapps/installations"), "UTF-8"), 'body': '', 'headers': [ HOST: "${hosthex}:${porthex}" , Authorization:userpass] )

Basically, admin:password is encoded in base64 then sent in the authorization HTTP header as Basic . The command is sent as POST to /concord/arm/stay

On Wed, Apr 4, 2018 at 9:19 PM, marbaugh notifications@github.com wrote:

Could you provide an example of how to include the base64 encoded string in the REST API call 'http://192.168.1.31:8066/concord/arm/stay'

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5#issuecomment-378793013, or mute the thread https://github.com/notifications/unsubscribe-auth/ANJf94mNtK76SFP4d66mGHbSYWqN8gQVks5tlXEhgaJpZM4PZqVS .

marbaugh commented 5 years ago

Any idea how I can get the system to do a silent disarm? I am trying to have it auto arm when getting in bed so the silent arm works but I then want it to disarm at a certain time in the morning without beeping. I can do it on the keypad but not sure about how to get smartthings/pyconcord to do it.

csdozier commented 5 years ago

See this thread https://github.com/csdozier/device-concord4/issues/4

On Wed, Oct 24, 2018 at 9:09 PM marbaugh notifications@github.com wrote:

Any idea how I can get the system to do a silent disarm?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csdozier/device-concord4/issues/5#issuecomment-432878885, or mute the thread https://github.com/notifications/unsubscribe-auth/ANJf9_rFvIWPtkqE4mpWbzecLiHL6iHpks5uoQ9agaJpZM4PZqVS .

marbaugh commented 5 years ago

Thanks this worked great.