Struggled with simply showing the status of something from HE in the Apple Home app. As a switch, it could also be commanded or turned off/on.
The Virtual Contact and Motion Sensor with Ignorable Switch is a virtual device driver to mirror a contact or motion sensor as a switch. However, toggling the switch on or off is ignored by default.
Use Cases
-
This is a useful hack in presenting a device in the Apple Home app to display the state of contact or motion sensors on the main Home page. This is simpler than opening the Security tab and then choosing Contact Sensors or Motion Sensors.
-
Allows the status of a device in Home to be displayed while preventing the accidental toggling of the switch. If the switch is toggled, its state will be restored. Examples: presence, doors/windows, other virtual switches such as mode or operating status
-
Instances where a device status needs to be reversed.
-
As a regular virtual device with contact, motion, and switch capabilities, just as other virtual device drivers.
Installation
Currently, manual installation by importing the driver code. Considering HPM in the future.
Preferences / Configuration
-
Reverse the switch behavior so an open contact or active motion is a switch which is OFF. By default, for Home use, an open contact or active motion is ON.
-
Ignore switch toggling is on by default. However, this can be turned off so the device is just a normal device and toggling the switch changes the state of the contact and motion.
Attributes that can be used in rules
- Contact - open / closed
- Motion - active / inactive
- Switch - on / off
- switchIsReversed - boolean true / false
- switchIsIgnored - boolean true / false
Limitation
This is a virtual device. A simple rule is still needed to mirror a real device. See future plans.
Future Plans
In order to manage a large number of status switches, I'm considering making an app to quickly create and manage all of the virtual devices and to link them to a real device so no additional rules need to be created.
I'm not a formally educated programmer. Comments and suggestions welcomed.