Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nikohomecontrol] Ability to add virtual flags without the need for a basic action #11740

Closed
sindalschmidt opened this issue Dec 9, 2021 · 10 comments · Fixed by #11751
Closed
Labels
enhancement An enhancement or new feature for an existing add-on

Comments

@sindalschmidt
Copy link

Expected behavior

The ability to add virtual devices without the need for a basic action to be assigned.

Current behavior

When having a PIR device added in OpenHAB, that PIR does not emit motion events. It's only possible to control as a push button. The PIR in Niko Home Control requires a device to control. So because the PIR, that is available in the OpenHAB binding, does not emit motion events, then one need to add the device that the PIR controls. When one sets this to a virtual flag, without a basic action, because one does not want this to show up as a switch in either the Niko Home App or Google Home, then it is not possible to add this virtual flag to OpenHAB.

image

Proposed solution

Allow the virtual flag to be added from the inbox.

The virtual flag, that has no basic action, seems to be available in the received topic hobby/control/devices/evt:

{
	"Name": "PIR",
	"Traits": [],
	"Model": "flag",
	"Type": "virtual",
	"Uuid": "c69b4f89-681e-4894-9871-6606e7802d96",
	"Identifier": "1e4482e6-e241-4be6-b808-ade90b64ad37",
	"Parameters": [
		{
			"LocationName": "Walk-in"
		},
		{
			"LocationId": "6941a084-5383-41e4-9df4-2df1191798f2"
		},
		{
			"LocationIcon": "dressing"
		}
	],
	"Technology": "nikohomecontrol"
}

And according to the logs, the binding does in fact receives updates from the virtual flag with no basic action, when in this example motion is detected by the PIR and it turns on the virtual flag:

2021-12-09 19:22:01.762 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic hobby/control/devices/evt, payload {"Method":"devices.status","Params":[{"Devices":[{"Properties":[{"Status":"True"}],"Uuid":"c69b4f89-681e-4894-9871-6606e7802d96"}]}]}

I have tried manually adding the device and refer to the Uuid in the Action ID, but the binding says Configured action ID does not match an action in controller

@mherwege

@sindalschmidt sindalschmidt added the enhancement An enhancement or new feature for an existing add-on label Dec 9, 2021
@mherwege
Copy link
Contributor

mherwege commented Dec 9, 2021

Do you see Niko events in the OH log when the device gets Triggered? This looks like the device definition, but not an actual trigger event. And I don’t see properties that would convey a state in it.

@sindalschmidt
Copy link
Author

sindalschmidt commented Dec 9, 2021

I'm not entirely sure if I understand where you want me to look. In the openhab.log file, it looks like the following (I included the event from a thermostat as well, to show that they are not that different, but still the OpenHAB binding reacts to it):

The virtual flag when walking past the PIR:
2021-12-09 21:15:46.582 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic hobby/control/devices/evt, payload {"Method":"devices.status","Params":[{"Devices":[{"Properties":[{"Status":"True"}],"Uuid":"c69b4f89-681e-4894-9871-6606e7802d96"}]}]}

A thermostat update:
2021-12-09 21:16:02.271 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic hobby/control/devices/evt, payload {"Method":"devices.status","Params":[{"Devices":[{"Properties":[{"AmbientTemperature":"23.00"}],"Uuid":"bcd71bfb-bbec-4092-a702-a1a275c54d86"}]}]}
2021-12-09 21:16:02.500 [DEBUG] [l.nhc2.NikoHomeControlCommunication2] - Niko Home Control: setting thermostat bcd71bfb-bbec-4092-a702-a1a275c54d86 with measured 230, setpoint 230, mode 0, overrule 230, overruletime 0, ecosave 0, demand 0
2021-12-09 21:16:02.543 [DEBUG] [trol.internal.protocol.NhcThermostat] - update channels for bcd71bfb-bbec-4092-a702-a1a275c54d86

@mherwege
Copy link
Contributor

mherwege commented Dec 9, 2021

Yes, that’s what I needed. Do you find somewhere in the log where it changes to false?
Model flag, type virtual, is not something I currently have in the binding.

could you try creating another type of action with only a virtual output? I would like to see if this behaviour is specific to a virtual flag connected to a PIR, or also other actions.

@sindalschmidt
Copy link
Author

Yes, it also sends a False message:

2021-12-09 21:17:47.721 [TRACE] [l.nhc2.NikoHomeControlCommunication2] - received topic hobby/control/devices/evt, payload {"Method":"devices.status","Params":[{"Devices":[{"Properties":[{"Status":"False"}],"Uuid":"c69b4f89-681e-4894-9871-6606e7802d96"}]}]}

I can also confirm that a virtual flag being turned on by a scene is also received, without the need for that virtual flag to have a basic action 🙂

@mherwege
Copy link
Contributor

mherwege commented Dec 9, 2021

I need to think this through a bit, but I could probably create a sensor type channel for these virtual flags (an OH contact). I expect you cannot control the virtual flag from the API, only receive status updates.

@sindalschmidt
Copy link
Author

sindalschmidt commented Dec 9, 2021

That would suffice. The reason I am trying to achieve this, is because in two different rooms in my house, the Niko sensors can't quite seem to catch a person in time, so I wanted to move the actual switch on/off functionality out of Niko and into OpenHAB, so I can add a Philips Hue motion sensor to the mix.

This way I can have both sensors trigger the same rule that runs a script with a timer to turn off lights again. Whenever either one of the sensors triggers motion, the script will reschedule. I have already tested this and it's working. Now I just need the inputs, without having a weird switch in Niko Home app and Google Home – achievable with a virtual flag without an action.

Let me know if I should test something. I will make sure to test it thoroughly 💯 👍

@mherwege
Copy link
Contributor

mherwege commented Dec 9, 2021

I just downloaded the latest version of the API doc. The version I had was a bit older. In this new version, the virtual flag is documented. And according to the doc, it can be controlled as well. As I can’t establish if it can, or cannot be controlled from the device definition, I will expose it as a switch. The one specific is that values are True or False, while other devices state values are On or Off. But I can take care of that inside the binding.

@mherwege
Copy link
Contributor

A new jar for your testing. The virtual flag should be detected as a switch type. I would be very interested in all use cases you have. I am probably able to replace some free actions in my installation with this.

@sindalschmidt
Copy link
Author

sindalschmidt commented Dec 10, 2021

It's working, but for a virtual flag that I had added as a thing and created a channel for before, but then removed that channel and thing again, I now see in the logs when that virtual flag (that has been removed as thing) is triggered:

2021-12-10 18:30:19.876 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler NikoHomeControlActionHandler of thing nikohomecontrol:onOff:443b00ee9a2f:c69b4f89-681e-4894-9871-6606e7802d96 tried updating channel switch although the handler was already disposed.
2021-12-10 18:30:19.883 [WARN ] [.core.thing.binding.BaseThingHandler] - Handler NikoHomeControlActionHandler tried updating the thing status although the handler was already disposed.

I can find the Uuid in my Inbox and I have checked that there are no leftover channels or items.

@mherwege
Copy link
Contributor

virtual flag (that has been removed as thing) is triggered

I see. This is nothing to be worried about, and would happen with any thing you remove. I need to check if there is a cleanup missing, or it is just a timing issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants