galadril / DomoticzForAndroid

This is a Domoticz Android app. Domoticz is a very light weight home automation system ...
http://www.domoticz.com
14 stars 7 forks source link

Security Panel #108

Closed galadril closed 8 years ago

galadril commented 8 years ago

Maybe implement a security panel just like how it's done in Domoticz? NOTE: I don't use this at the moment, so don't know how this works. you maybe remb0??

security

RoadXY commented 8 years ago

Milestone for v2?

remb0 commented 8 years ago

I don't use this functions right now But can test it if you want. there is a forum member willing to go premium if this function is done :)

galadril commented 8 years ago

Just some information about the security panel:

Get Password: GET http://ip:port/json.htm?type=settings JSON: "SecPassword" : "2adcefe38fbcd3dcd45908fbab1bf628",

ARM HOME: GET http://ip:port/json.htm?type=command&param=setsecstatus&secstatus=1&seccode=2adcefe38fbcd3dcd45908fbab1bf628

ARM AWAY: http://ip:port/json.htm?type=command&param=setsecstatus&secstatus=2&seccode=2adcefe38fbcd3dcd45908fbab1bf628

DISARM: http://ip:port/json.htm?type=command&param=setsecstatus&secstatus=0&seccode=2adcefe38fbcd3dcd45908fbab1bf628

GET STATUS GET http://ip:port/json.htm?type=command&param=getsecstatus

Example Switch Device JSON: { "AddjMulti" : 1.0, "AddjMulti2" : 1.0, "AddjValue" : 0.0, "AddjValue2" : 0.0, "BatteryLevel" : 100, "CustomImage" : 0, "Data" : "Normal", "Description" : "", "Favorite" : 0, "HardwareID" : 1000, "HardwareName" : "Unknown?", "HardwareType" : "Unknown?", "HardwareTypeVal" : 0, "HaveDimmer" : false, "HaveGroupCmd" : false, "HaveTimeout" : false, "ID" : "148702", "LastUpdate" : "2015-10-26 19:42:41", "MaxDimLevel" : 0, "Name" : "Security panel", "Notifications" : "false", "PlanID" : "0", "PlanIDs" : [ 0 ], "Protected" : false, "ShowNotifications" : true, "SignalLevel" : 6, "Status" : "Normal", "StrParam1" : "", "StrParam2" : "", "SubType" : "Security Panel", "SwitchType" : "Security", "SwitchTypeVal" : 0, "Timers" : "false", "Type" : "Security", "TypeImg" : "security", "Unit" : 0, "Used" : 1, "XOffset" : "0", "YOffset" : "0", "idx" : "65" },

hansworst24 commented 8 years ago

Did this got implemented for DomoticzForAndroid ? I'm building a Windows Phone app, Ticz, which I'd like to have the same functionality. The JSON requests are straight forward, but how to validate a user input password against the SecPassword, to see if it matches... ?

hansworst24 commented 8 years ago

In case you might want to implement this for your App. I figured out how to handle the entered code and compare it with the hashed password. It requires the code to be hashed with MD5. The rest of the Security Panel is relatively simple, and I got it fully working for Windows 10 :)

In VB.Net the code below handles the hashing, and might be of help when implementing it for your app !

Public Sub CreateSecurityHash()
        Dim codeBuffer As IBuffer = CryptographicBuffer.ConvertStringToBinary(CodeInput, BinaryStringEncoding.Utf8)
        Dim alg As HashAlgorithmProvider = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Md5)
        Dim buffHash As IBuffer = alg.HashData(codeBuffer)
        If Not buffHash.Length = alg.HashLength Then
            Throw New Exception("There was an error creating the hash")
        Else
            CodeHash = CryptographicBuffer.EncodeToHexString(buffHash)
        End If

    End Sub
galadril commented 8 years ago

this is already implemented for quite some time now in our app..

But we've moved to another github place: https://github.com/domoticz/domoticz-android

hansworst24 commented 8 years ago

ok, thanks :) I encountered this repository when searching for a way to convert the code to the required hash :)