Niko Home Control II

Haha, that’s me as well :wink:

@froye Did you manage to solve the issue somehow?

No, i haven’t.
The discussion was continued here:
https://github.com/filipvh/hass-nhc2/issues/42

Hi Mark

Long time since I’ve been bugging you! But I have a new request :slightly_smiling_face:

When enabling the alarm in Niko Home Control I would like to react to the “prearmed” state, as in from when you initially press the button until it is armed. Right now we can add the button in OpenHAB, but the channel first changes to “ON” when the alarm is armed. Not in the pre-arm state. I’m not sure how to do this properly other than having a secondary channel. Any good ideas on how to accomplish this?

2022-12-22 21:08:36.237 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"PreArmed"},{"BasicState":"Intermediate"},{"Control":"Activate"}]}]}],"Method":"devices.status"}
2022-12-22 21:08:39.832 [DEBUG] [very.NikoHomeControlDiscoveryService] - getting devices on 443b00ee9a2f
2022-12-22 21:08:41.247 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"Armed"},{"AlarmActive":"True"},{"BasicState":"On"}]}]}],"Method":"devices.status"}
2022-12-22 21:08:41.247 [DEBUG] [econtrol.internal.protocol.NhcAction] - update channel state for d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca with 100
2022-12-22 21:08:41.248 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting action d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca internally to ON
2022-12-22 21:08:41.248 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HusalarmHjemNiko_Button' changed from OFF to ON
2022-12-22 21:08:43.429 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"Off"},{"AlarmActive":"False"},{"BasicState":"Off"},{"Control":"Deactivate"}]}]}],"Method":"devices.status"}
2022-12-22 21:08:43.430 [DEBUG] [econtrol.internal.protocol.NhcAction] - update channel state for d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca with 0
2022-12-22 21:08:43.430 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting action d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca internally to OFF
2022-12-22 21:08:43.431 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'HusalarmHjemNiko_Button' changed from ON to OFF

@thomas93 That is a tough one. The code currently only looks for BasicState On/Off if that is available, and does not do anything with InternState. Also BasicState Intermediate is ignored, as these controls are mapped to on/off switches in OH that cannot take that imtermediate state.
To solve this, I would need to specifically identify the types of controls where this is relevant and create another channel type for it (probably string with multiple values).
Can you provide the log at initialization of all the devices, so I can identify the alarm device?

Hi Mark

Happy holidays. I believe I’ve been able to locate the correct information:

"Uuid": "d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca",
"Identifier": "e2090b50-8da3-4998-a02f-15a68468e084",
"Model": "alarms",
"Online": "True",
"Name": "Husalarm",
"Technology": "nikohomecontrol",
"Type": "action",
"Traits": [],
"Parameters": [
	{
		"LocationName": "Hjem"
	},
	{
		"LocationId": "674631d1-8c0b-4a88-a7d6-f42cc454de9e"
	},
	{
		"LocationIcon": "general"
	},
	{
		"IconCode": "panic"
	}
],
"Properties": [
	{
		"InternalState": "Off"
	},
	{
		"AlarmActive": "False"
	},
	{
		"AlarmTriggered": "False"
	},
	{
		"BasicState": "Off"
	},
	{
		"Control": "Deactivate"
	}
],
"PropertyDefinitions": [
	{
		"InternalState": {
			"HasStatus": "true",
			"CanControl": "false",
			"Description": "Choice(Off,PreArmed,DetectorProblem,Armed,PreAlarm,Alarm)"
		}
	},
	{
		"AlarmActive": {
			"HasStatus": "true",
			"CanControl": "false",
			"Description": "Boolean"
		}
	},
	{
		"AlarmTriggered": {
			"HasStatus": "true",
			"CanControl": "false",
			"Description": "Boolean"
		}
	},
	{
		"BasicState": {
			"HasStatus": "true",
			"CanControl": "true",
			"Description": "Choice(On,Intermediate,Off,Triggered)"
		}
	},
	{
		"Control": {
			"HasStatus": "true",
			"CanControl": "true",
			"Description": "Choice(Activate,Deactivate)"
		}
	}
]

Is this sufficient? :slightly_smiling_face:

Yes, that helps a lot. One more thing though. It would help to see what messages get sent from NHC when the alarm is triggered.
It looks like I should probably create a specific action type for alarms. And I should then consider all functionality.
This may take a while though. There is still a pending PR with improvements, and I don’t want to add much functionality as long as that doesn’t get approved and merged. Otherwise, things start to get difficult to keep all in sync.

Hi Mark. Sounds good. No problem.

I might be able to get some messages during the weekend, if I get time. Just curious, do you not use NHC II for intruder alert yourself? :slightly_smiling_face:

No, I don’t. I have an older alarm system, maintained by a security company. The only link is a relay which gets activated when an alarm goes off, and gets sent to NHC with some logic there for lights and notifications.

Hi Mark

Here is the logs for when pressing the “arm” button, waiting 2 minutes until it is armed and then shortly afterwards disarming it again:

2023-01-11 20:16:10.934 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"8c43c94c-3db0-44ae-b121-a2e4ffaf28d4","Properties":[{"InternalState":"Off"},{"BasicState":"Off"},{"Control":"Deactivate"}]}]}],"Method":"devices.status"}
2023-01-11 20:16:10.935 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting action 8c43c94c-3db0-44ae-b121-a2e4ffaf28d4 internally to OFF
2023-01-11 20:16:33.147 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"8c43c94c-3db0-44ae-b121-a2e4ffaf28d4","Properties":[{"InternalState":"PreArmed"},{"BasicState":"Intermediate"},{"Control":"Activate"}]}]}],"Method":"devices.status"}
2023-01-11 20:18:32.707 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"8c43c94c-3db0-44ae-b121-a2e4ffaf28d4","Properties":[{"InternalState":"Armed"},{"AlarmActive":"True"},{"BasicState":"On"}]}]}],"Method":"devices.status"}
2023-01-11 20:18:32.708 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting action 8c43c94c-3db0-44ae-b121-a2e4ffaf28d4 internally to ON
2023-01-11 20:19:10.744 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"8c43c94c-3db0-44ae-b121-a2e4ffaf28d4","Properties":[{"InternalState":"Off"},{"AlarmActive":"False"},{"BasicState":"Off"},{"Control":"Deactivate"}]}]}],"Method":"devices.status"}
2023-01-11 20:19:10.745 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting action 8c43c94c-3db0-44ae-b121-a2e4ffaf28d4 internally to OFF

Having these states will also be beneficial when setting up Homekit and Google Assistant through OpenHAB. Let me know if you need anything else, as always! :grinning:

I had a go at it. Here is a compiled jar file.
You will need to remove the alarm thing and recreate it from discovery. There should be 3 channels now: an on/off to enable/disable the alarm, a readonly string channel with the alarm state (ARMED, DISARMED, PREARMED or TRIGGERED) and a trigger channel that should trigger when the alarm goes off.
I can’t test this, so up to you to verify.
Also try to have an alarm get triggered and see if the state and trigger channel react correctly.

1 Like

Not sure if it is related but on the 14th of october I went to Niko for a user interview. One of the questions was if I would want to pay for a live videostream in my app. I said no, the unit costs enough already and I can acces the stream already on my network and VPN with the default functionality of that doorbell that is actually from another supplier.

I don’t know what the reason is, but given the question above and the behavior now, I can only think that they blocked this on purpose… Let’s hope it was unintentional and they will fix it soon.

Awesome! I’m currently running OH 3.4.1, but it seems that your jar file is compiled for version 3.4.0. Does this matter?

Also, should I remove the binding through the GUI before placing the compiled jar file in the addons folder or can they co-exist, if OH will prioritize the jar file in the addons folder?

It should work with 3.4.1 as well.
You will need to deinstall from the GUI before dropping the jar file in.

Hi Mark.
Unfortunately the state channel does not seem to work properly – it does not change from NULL.

There also needs to be additional channels to be compatible with Homekit and Google assistant.

We need the following channels:

  1. Switch: Showing current state (ON/OFF). Should turn “ON” when alarm is succesfully armed. This was the original functionality.
  2. Switch: Showing target state (ON/OFF). Should turn “ON” immediately when alarm is being enabled. This is the new functionality.
  3. String: Showing current state (Off/PreArmed/DetectorProblem/Armed/PreAlarm/Alarm). This can be taken from the “InternalState” value.
  4. String: Showing target state (Off/Armed)

Point 1 will provide support for Google Assistant while 3 and 4 will provide support for HomeKit.

Timeline for below:
17:48:19 Alarm is disabled.
17:51:53 Alarm is enabled (Entering PreArmed that is configured to run for 30 seconds before arming, if no problems are detected when those 30 seconds run out).
17:52:23 30 seconds run out, but a motion detector is active.
17:52:36 Motion detection stops, starts PreArmed again (Not sure why next event is 60 seconds and not 30 seconds as I would have expected… anyways! :smile:)
17:53:36 Alarm is armed.
17:53:40 Alarm is triggered, goes into PreAlarm state, which is configured to last for 15 seconds (allows one to flash lights to remind you to disarm it quickly, before it enters alarm state.
17:53:55 Timer is up, goes into Alarm state. (I suppose this is when the new trigger channel will be triggered)
17:54:07 Alarm is disabled.

2023-01-22 17:48:19.185 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"Off"},{"BasicState":"Off"},{"Control":"Deactivate"}]}]}],"Method":"devices.status"}
2023-01-22 17:48:19.185 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting alarm device d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca state to Off
2023-01-22 17:48:19.186 [DEBUG] [mecontrol.internal.protocol.NhcAlarm] - update channel state for d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca with Off
2023-01-22 17:51:53.544 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"PreArmed"},{"BasicState":"Intermediate"},{"Control":"Activate"}]}]}],"Method":"devices.status"}
2023-01-22 17:51:53.545 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting alarm device d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca state to Intermediate
2023-01-22 17:51:53.545 [DEBUG] [mecontrol.internal.protocol.NhcAlarm] - update channel state for d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca with Intermediate
2023-01-22 17:52:23.542 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"DetectorProblem"}]}]}],"Method":"devices.status"}
2023-01-22 17:52:36.417 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"PreArmed"}]},{"Uuid":"34d0e6f8-f8c1-4dfb-a082-75ffc4552c95","Properties":[{"MotionDetected":"False"}]}]}],"Method":"devices.status"}
2023-01-22 17:53:36.482 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"Armed"},{"AlarmActive":"True"},{"BasicState":"On"}]}]}],"Method":"devices.status"}
2023-01-22 17:53:36.483 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting alarm device d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca state to On
2023-01-22 17:53:36.483 [DEBUG] [mecontrol.internal.protocol.NhcAlarm] - update channel state for d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca with On
2023-01-22 17:53:40.615 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"76805124-8a25-473c-a320-ba4d66ff2de9","Properties":[{"Status":"True"}]},{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"PreAlarm"}]},{"Uuid":"34d0e6f8-f8c1-4dfb-a082-75ffc4552c95","Properties":[{"MotionDetected":"True"}]}]}],"Method":"devices.status"}
2023-01-22 17:53:55.655 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"550da6d5-e622-4091-b123-6a6b48aac04e","Properties":[{"Status":"True"}]},{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"Alarm"},{"AlarmTriggered":"True"}]}]}],"Method":"devices.status"}
2023-01-22 17:54:07.267 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"76805124-8a25-473c-a320-ba4d66ff2de9","Properties":[{"Status":"False"}]},{"Uuid":"550da6d5-e622-4091-b123-6a6b48aac04e","Properties":[{"Status":"False"}]},{"Uuid":"d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca","Properties":[{"InternalState":"Off"},{"AlarmActive":"False"},{"AlarmTriggered":"False"},{"BasicState":"Off"},{"Control":"Deactivate"}]}]}],"Method":"devices.status"}
2023-01-22 17:54:07.269 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting alarm device d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca state to Off
2023-01-22 17:54:07.270 [DEBUG] [mecontrol.internal.protocol.NhcAlarm] - update channel state for d7c29d91-10ff-4995-b2b7-4cfb6e8e72ca with Off

I didn’t work on adding/changing channels yet. But I did find an error in the code updating the channels. Can you try this version.

Alright! Truly appreciate your work – and I know a lot of others do as well :+1: I will give it a try during the weekend.

Looking forward to the additional channels and testing it with Google Assistant and Homekit! :slightly_smiling_face:

Hi. Unfortunately it still does not seem to update the string item channel. I tried re-adding the channel, re-adding the item as well as re-adding the whole ‘thing’.

Below log from re-adding it to arming the alarm, but the ‘alarm state string channel’ stays NULL.

2023-01-29 15:00:47.321 [INFO ] [g.discovery.internal.PersistentInbox] - Added new thing 'nikohomecontrol:alarm:443b00ee9a2f:8c43c94c-3db0-44ae-b121-a2e4ffaf28d4' to inbox.
2023-01-29 15:00:47.321 [INFO ] [openhab.event.InboxAddedEvent       ] - Discovery Result with UID 'nikohomecontrol:alarm:443b00ee9a2f:8c43c94c-3db0-44ae-b121-a2e4ffaf28d4' has been added.
2023-01-29 15:01:04.563 [INFO ] [openhab.event.InboxRemovedEvent     ] - Discovery Result with UID 'nikohomecontrol:alarm:443b00ee9a2f:8c43c94c-3db0-44ae-b121-a2e4ffaf28d4' has been removed.
2023-01-29 15:01:04.565 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'nikohomecontrol:alarm:443b00ee9a2f:8c43c94c-3db0-44ae-b121-a2e4ffaf28d4' changed from UNINITIALIZED to INITIALIZING
2023-01-29 15:01:04.569 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'nikohomecontrol:alarm:443b00ee9a2f:8c43c94c-3db0-44ae-b121-a2e4ffaf28d4' changed from INITIALIZING to UNKNOWN
2023-01-29 15:01:04.570 [DEBUG] [l.handler.NikoHomeControlBaseHandler] - device initialized 8c43c94c-3db0-44ae-b121-a2e4ffaf28d4
2023-01-29 15:01:04.571 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'nikohomecontrol:alarm:443b00ee9a2f:8c43c94c-3db0-44ae-b121-a2e4ffaf28d4' changed from UNKNOWN to ONLINE
2023-01-29 15:01:19.032 [DEBUG] [.handler.NikoHomeControlAlarmHandler] - handle command REFRESH for nikohomecontrol:alarm:443b00ee9a2f:8c43c94c-3db0-44ae-b121-a2e4ffaf28d4:switch
2023-01-29 15:01:26.850 [DEBUG] [.handler.NikoHomeControlAlarmHandler] - handle command REFRESH for nikohomecontrol:alarm:443b00ee9a2f:8c43c94c-3db0-44ae-b121-a2e4ffaf28d4:state
2023-01-29 15:01:37.921 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic c516c66a-4970-4a45-817b-d912871e9033/control/devices/evt, payload {"Params":[{"Devices":[{"Uuid":"8c43c94c-3db0-44ae-b121-a2e4ffaf28d4","Properties":[{"InternalState":"PreArmed"},{"BasicState":"Intermediate"},{"Control":"Activate"}]}]}],"Method":"devices.status"}
2023-01-29 15:01:37.922 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - setting alarm device 8c43c94c-3db0-44ae-b121-a2e4ffaf28d4 state to Intermediate
2023-01-29 15:01:37.922 [DEBUG] [mecontrol.internal.protocol.NhcAlarm] - update channel state for 8c43c94c-3db0-44ae-b121-a2e4ffaf28d4 with Intermediate

I think I found what the issue was. I created a new jar, download from the same location. I did not work on all extra channels yet, just wanting to make sure this works before doing that.

Hi Mark. I was just going over the repo again and saw that the file changed a few minutes ago :grinning: I will give it a try right now!