Simulated device, part switch, part sensor

I searched through prior posts and there isn’t a clear answer, I’m trying to replace my SmartThings virtual devices (Simulated Alexa Switch/sensors) with HA.

The equivalent to bjpierron’s Simulated Alexa Switch, device class, which uses SmartThings IDE and allows you to create devices that Alexa recognizes as a switch and sensor. So it’s a virtual device on SmarThings side with two entities, an on/off switch, and an open/closed sensor.

The key is that the switch and sensor are virtually synchronized, so that if the switch is on, the sensor reads open, and when the switch is off, the sensor reads closed.

My use cases are for Alexa, but no reason it couldn’t be made compatible with Google Home, and provide a switch which Alexa can turn off or on, and a sensor that can be used to trigger routines.

Example uses:

Any device that can’t be directly integrated into HA, but does have Alexa compatibility.

  1. I have a Wyze door sensor, when the sensor is opened, I trigger a routine to turn on the virtual switch, and when the sensor is closed, I trigger a routine to turn off the virtual switch.

This automatically changes the state of the virtual devices sensor (switch on → sensor open, switch off → sensor closed).

This would allow the two way control/communication between Alexa and HA, allowing HA to “see” the state of the Wyze door sensor.

  1. I can use the virtual device to trigger Alexa routines. By exposing the door sensor entity of the virtual device, I can then use the new Alexa sensor as a trigger for any routine. By setting the switch on, the door sensor entity would open, and any Alexa routine using the virtual sensor would be triggered.

The key part is to have the ability to create these virtual switch/sensor devices, and have the state of the switch and sensor be synchronized automatically, no automations needed.

The github repository for the Smartthings device is here:

There’s a ton of different ways to do this. Input_boolean, template switch, template binary_sensor, automations. Choose your poison.

Trying to have this be a device type that I don’t have to automate on each instance.
So, I can create the device, and have the housekeeping done automatically.

  1. How do I create a virtual sensor that Alexa will recognize, that’s not clear on the HA side.
  2. How would I create a synchronization of these devices (between their switch and sensor states).

Using a template binary sensor.

Template binary sensors automatically synchronize with whatever entity you attach it to using a template.

e.g.

template:
- binary_sensor:
  - name: virtual sensor
    state: "{{ states('input_boolean.xyz') }}"

Most domains transfer to Alexa by default. So you really just need to make your