I really like this device! I have 7 of them in fact. It is special in that it can handle heavier loads like refrigerators and fans that many other smart plugs can’t. It also reports various electrical-related values like Current, Voltage, Power as well as cumulative Energy usage. This functionality, along with some of its other built-in features, makes it the perfect device for controlling and monitoring important devices that need to remain ON.
Not only do I use them to control fans based upon temperature readings, but I also developed functionality in Home Assistant to monitor the status of my two refrigerators and a freezer. This may not sound too exciting, until you’ve had a compressor fail on a freezer or there is an extended mains power outage, or a breaker trips while you are away from home, and you lose hundreds of dollars worth of food, including the spoils of last season’s Caribou hunt (no pun intended).
The YAML code provided below is used to define automations, scripts, and input parameters that I use in Home Assistant to monitor the status of my two refrigerators and freezer. These have been tested and are working well for me, so I wanted to share the details if others are interested in doing something similar. I have the automation, script, sensor, and input variable code in separate configuration files, but all of it can appear in your configuration.yaml
file.
For brevity, I’ve included only the parts that apply to my freezer unit, but the other two devices are similar. Each device will differ in its run characteristics and must thereforet be tuned for a particular device, which I will get to later.
Before I jump into the YAML, I need to point out how I have the ZEN15’s Configuration Class Parameters configured, as this is integral to proper operation of the automations. Below, I list the Parameter : Description = Value as I have them configured (as they appear with Firmware Version 1.06):
20: Overload Protection = Enabled
21: State After Power Failure = Always On
24: On/Off Status Change Notifications = When controlled manually or via Z-Wave
27: LED Power Consumption Indicator = Always On
30: Manual Control = Disable
33: Auto-On Timer = Disable
34: Auto-Off Timer = Disable
151: Power Report Value Threshold = Disable
152: Power Report Percentage Threshold = Disable
171: Power Report Frequency = 60 Seconds
172: Energy Report Frequency = 3600 Seconds
173: Voltage Report Frequency = 60 Seconds
174: Electricity Report Frequency = Disable
I report Power and Voltage every minute, but Energy usage every Hour since energy is not necessary for the automations. But I do display Energy in the UI. I also ensure that the switch on the ZEN15 is disabled from manual control.
Before I get to the automations and scripts, there are a few entities I define that are used in them, as well as in the UI, which I describe next. I define two Input Booleans in configuration.yaml
as follows:
input_boolean:
freezer_power_supply_monitor_ib:
name: Freezer Power Supply Monitor (IB)
icon: mdi:power-plug-outline
freezer_unit_monitor_ib:
name: Freezer Unit Monitor (IB)
icon: mdi:thermometer-low
When I created this functionality, I used an automation to control a third Input Boolean, but with the recent addition of the Template Sensors, it was replaced by the much more succinct code used to create the binary sensor shown below:
template:
- binary_sensor:
- unique_id: freezer_running_monitor_bst
name: Freezer Running Monitor (BST)
icon: mdi:power
state: "{{states('sensor.zooz_zen15_power_cord_freezer_power')|float > 50}}"
With these two Input Booleans and Binary Sensor defined, I can describe the heart of the functionality in my HA UI that shows me the status of my devices. In it, I have an all-encompassing Status Card utilizing Button Cards that give me a complete view of the state of all of my relevant devices controlled by HA, including the freezer, which uses the three buttons shown below:
The leftmost button (power icon) is green if the ZEN15 is switched ON, and red if it is switched OFF. It is associated with the ZEN15 switch entity itself. The middle button (plug icon) turns red if mains power to the ZEN15 is lost (either through a power outage or it is unplugged). It is associated with the Input Boolean input_boolean.freezer_power_supply_monitor_ib
. The rightmost button (thermometer) turns red if the freezer device has been unplugged from the ZEN15 or the unit fails (e.g., relay or compressor). It is associated with the Input Boolean input_boolean.freezer_unit_monitor_ib
. If any of these turn red, I also send a persistent notification to my mobile devices.
To help with developing and tuning the automations, I created the entities card shown below to show the Power used and the state of the Template Binary Sensor defined earlier indicating whether the device is ON (running) or OFF (resting). I include this Binary Sensor in my HA Recorder section in configuration.yaml
so I can view the ON/OFF pattern in History over a period of time to get a feel for how it operates. I delve deeper into the tuning later.
As a safety feature to guard against accidentally switching off the ZEN15 via Z-Wave (since manual control is disabled), I have an automation that is triggered if the ZEN15 is turned off, which immediately turns it back on and sends a notification to my mobile device. That Automation code is as follows:
#
# RESTORE POWER STATE TO ON
#
# Freezer Power Cord Turned Off
# Manual Control is Disabled for Protection (Parameter 30)
- id: freezer_power_cord_turned_off_atm
alias: Freezer Power Cord Turned Off
trigger:
platform: state
entity_id: switch.zooz_zen15_power_cord_freezer_switch
to: 'off'
action:
- service: homeassistant.turn_on
entity_id: switch.zooz_zen15_power_cord_freezer_switch
- service: script.notify_scr
data:
service: ALL_DEVICES
title: Freezer Warning
message: Freezer Power Cord Turned Off (Turning Back On)
In the above automation, I call a script for the notification in order to pass parameters. I have one script that I can call with a variety of messages to avoid redundancy. That Script is as follows (this is designed for iOS and may be different for Android):
# Notify Script (parameters)
notify_scr:
alias: Notify Script (SCR)
mode: queued
sequence:
- service: notify.{{ service }}
data_template:
title: "{{ title }}"
message: "{{ message }}"
data:
push:
sound:
name: default
critical: 1
volume: 1.0
- service: persistent_notification.create
data:
title: "{{ title }}"
message: "{{ message }}"
The ALL_DEVICES in the notify_scr
call in the automation above is a notify group defined as follows in configuration.yaml
:
notify:
- name: ALL_DEVICES
platform: group
services:
- service: mobile_app_iphone...
- service: mobile_app_iphone...
- service: mobile_app_ipad...
The automation below monitors the mains power end of the ZEN15 and controls the middle button in the UI (plug icon). It is triggered when the voltage reported by the ZEN15 hasn’t changed in 20 minutes. This must be tuned for your particular power grid. Mine changes readily to show differences in values reported to HA. If the ZEN15 loses power via mains outage or being unplugged, it stops reporting to HA, and after 20 minutes (in my case), this automation fires. There are two conditions that must be met once triggered, although only the first is required. The first condition filters out any state changes that are caused by any attribute other than voltage (which happens when there is no from:
or to:
in the trigger). The second condition prevents the action:
from running if HA already knows about a mains power outage (through other means like the binary sensor provided by my Ecolink Chime/Siren). It was added to eliminate a cascade of power outage notifications for the freezer (and two refrigerators) in the case of an actual power outage. Ultimately, the automation simply turns on the Input Boolean input_boolean.freezer_power_supply_monitor_ib
and sends a notification to my mobile device. Once the icon on the Button Card turns red, it remains that way until it is manually toggled OFF, i.e., I do not reset it automatically, although one could. The automation is as follows:
# Freezer Power is Off
# Manual Control is Disabled for Protection (Parameter 30)
- id: freezer_power_supply_monitor_atm
alias: Freezer Power Supply Monitor (ATM)
trigger:
platform: state # if voltage remains the same for
entity_id: sensor.zooz_zen15_power_cord_freezer_voltage
for: '00:20:00'
condition:
- condition: template # after last change, cord power lost
value_template: "{{ trigger.to_state.state != trigger.from_state.state }}"
- condition: template
value_template: >
{{
is_state('binary_sensor.ecolink_chime_siren_mains_disconnected','on')
}}
action:
- service: homeassistant.turn_on
entity_id: input_boolean.freezer_power_supply_monitor_ib
- service: script.notify_scr
data:
service: ALL_DEVICES
title: Freezer
message: Power Failure
The following automation monitors the freezer unit end of the ZEN15, i.e., the operational status of the freezer unit itself, and controls the rightmost button in the UI (thermometer icon). It is triggered when the freezer’s power drops below the unit’s operational rest threshold of 50W for 2 hours. These two values must be tuned to your particular device and requires a bit more effort than in the last trigger due to the variables involved. Each unique device uses differing amounts of power when running, even moreso when the door is opened and the light comes on. Older devices, such as my vintage 1980s refrigerator, uses 16W of power even when it is resting (not running), so you can’t assume that not running equals zero power. Using the information provided by the Entities Card above for a while, I could determine the Power used when the device was running (including opening the doors, running the ice dispenser, etc.), as well as when the device was resting. These gave me operational Power boundaries for the device.
In the case of my freezer, that was about 80 to 100W when running, and 0W when resting. It was sufficient, then, to choose a value of 50W as the threshold, below which I could be confident that the device was not running and above which it was running. That value appears in the below:
statement in the trigger. The second part of the tuning is to determine the duty cycle of the device, or how long they run, on average, and how long they rest, on average. This is where the History data for the Running Monitor Input Boolean is helpful.
Once you have the Running Monitor Input Boolean recorded in history for some time, you can see an ON/OFF pattern emerge, and can determine the maximum period of time that the device rests between runs under various conditions. This value is the minimum value (length of time) that you should use in your trigger in the for:
statement. I found I had to keep increasing mine after a few false alarms, and 2 hours has been a good number. That’s a very long time for a refrigerator, but this is a deep freeze, which remains cold for many hours absent power. That is, it can remain at rest for an hour or two between runs while perfectly operational. For comparison, I ended up using a below:
value of 100 and a for:
time of 30 minutes for the older refrigerator, and a below:
value of 50 and a for:
time of 50 minutes for the much more efficient, newer refrigerator. In this automation, I included only the single condition to check if a power outage has been reported as before, and then turn on the Input Boolean input_boolean.freezer_unit_monitor_ib
followed by a notification sent to my mobile device. As a result, this turns the rightmost icon in the UI red.
# Freezer Unit Failure
# Manual Control is Disabled for Protection (Parameter 30)
- id: freezer_unit_monitor_atm
alias: Freezer Unit Monitor (ATM)
trigger:
platform: numeric_state # if power drops below operational rest levels for
entity_id: sensor.zooz_zen15_power_cord_freezer_power
below: 50
for: '02:00:00'
condition:
- condition: template
value_template: >
{{
is_state('binary_sensor.ecolink_chime_siren_mains_disconnected','on')
}}
action: # the unit has failed
- service: homeassistant.turn_on
entity_id: input_boolean.freezer_unit_monitor_ib
- service: script.notify_scr
data:
service: ALL_DEVICES
title: Freezer
message: Unit Failure
I have done this for all three of my refrigeration devices and it has been working flawlessly for the past year. The setup provides peace of mind knowing that I will be notified no matter where I am if there is a mains power outage, my units are accidentally unplugged, a breaker trips, or a refrigeration unit fails, so I can act to save the food stored inside. I’ve received so much from others on this forum, so wanted to give a little back.
How do YOU use YOUR ZEN15?