I use Amazon plugs with HA. Unfortunately, I donât think there is any way to directly control, so you have to do a little extra work.
Alexa allows you to trigger routines with template binary sensors that are of the âgarage doorâ type. So you create an input boolean, and then create a template sensor (type garage door) that is triggered by the input boolean. For example:
input_boolean:
alexa_fwd_charger:
name: "Charger"
binary_sensor:
- platform: template
sensors:
- alexa_fwd_charger:
friendly_name: "FWD-TRG-Device Charger"
device_class: garage_door
value_template: "{{ is_state('input_boolean.alexa_fwd_dev_charger', 'on') }}"
Now, whenever you turn on the input_boolean, the sensor/garage door opens. Same in reverse. Now, you just need to create two routines in the Alexa app. The first says that when the garage door opens, the Amazon plug turns on, and the second says when the garage door closes, the plug turns off.
Then, the plug will turn on and off as per the the input_boolean, which you can control either in HA or by voice via Alexa (since Alexa can control HA input booleans).
Finally, here is my advice about the coding names and friendly_names to use. You want a naming scheme that is easy to remember, wonât confuse Alexa, and which will keep HA and Alexa in sync (i.e., you donât want HA believing that a device is off while Alexa believes the device is on). The best way to keep devices in sync is to only control them via the input_boolean. To accomplish this, you want the input_boolean to have the natural sounding friendly name that is easy to remember, and you want to give the binary_sensor and the Amazon plug friendly names that you would never, ever say out loud, but which are easy to recognize and remember.
So (as per my example above) if you want to control a charger that is plugged into an Amazon plug, give the input_boolean the friendly name âChargerâ, the binary_sensor the friendly name âFWD Chargerâ (or âTRG Chargerâ), and in the Alexa app name the Amazon plug âDev - Charger.â That way, when you say âturn on chargerâ to Alexa, it always turns on the input_boolean (and only the input_boolean), keeping everything in sync. Further, when you are in your Alexa app, you will know that devices named âDev - xxxxxâ are devices that are being controlled by input booleans, and therefore that any Alexa routines should control the input_boolean and not the âDev - xxxxxxâ devices.
Of course, this will only keep the devices in sync if they are controlled exclusively by voice (Alexa) and HA. If you also control it physically, by pressing the on button on the plug, then you need to create some additional automations.
For the HA coding names (e.g., âinput_boolean.xxxxx_xxxxâ), I always start the code names of Amazon plugs with âalexa_fwdâ (e.g., input_boolean.alexa_fwd_charger). That way, you can group them all together in a single card on the HA Overview screen by creating monster cards that contain - entity: input_boolean.alexa_fwd*.
Hope that helps someone.