Fun with the Zooz ZEN15 Power Cord

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:

image

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.

image

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?

8 Likes

Nice write-up Shane. I just starting using a couple of ZEN15’s and I may use some of your code/ideas with my setup. I do have one question, Do you reset the KW values the ZEN15 reports, and if so, what command do you use?

There are two ways to reset the kWh meter on the ZEN15. If you are using zwavejs2mqtt to manage your Z-Wave, then in the Meter section of the device in the Control Panel, there is a “Reset Accumulated Values” button that will do it as shown below.

Also, according to this post on the Zooz support page, you can also do it manually at the device using the z-wave button as follows:

Firmware: 1.04

  • Added the ability to reset kWh meter locally at the plug (press the Z-Wave button 6 times quickly to reset)

That’s the on/off switch.

Hope that helps.

Cheers!

Thanks for the response @GrizzlyAK, I apologize, I was aware of the manual ways of resetting the meter’s, what I’m looking for is a way to do it via a Home Assistant automation. I currently do it nighty for some Shelly EM devices and was looking to do the same for the ZEN15’s. I have reached out to ZOOZ support, but they mentioned it should be in the HomeAssistant/JS documentation, which has me confused as I would think it would need to be a defined ZEN15 command. I can see from the Reset feature in the Meter Section that the reset function is a command of [100-50-0-reset], but I am unable to figure out how to send that to the device via an automation.

Regards,

I received feedback from the ZOOZ support team and was able to come up with a solution that works.

Here is the automation code I created to reset the meter values of my ZEN15’s.

alias: Nightly ZEN15 Meter Reset
description: ''
trigger:
  - platform: time
    at: '23:59:59'
condition: []
action:
  - service: zwave_js.set_value
    data:
      command_class: '50'
      property: reset
      value: true
    target:
      device_id: your_device_id
mode: single
1 Like

Ah, OK. Using Services in the Developer Tools, I was able to get the following automation action to work to reset the ENERGY meter on my ZEN15’s. That is the only one that accumulates a value, and thus reset. You need to determine your Device ID for this (you can do that several ways).

service: zwave_js.reset_meter
data:
  value: '0'
  meter_type: '1'
target:
  device_id:  << PUT YOUR DEVICE ID HERE >>

Some testing showed that I was unable to actually SET a value. If I put ‘200’ as the value, it would still rest to zero, so not sure what that data KEY is for. Also, I tried it with just either the meter_type or value parameters alone, and neither worked. Nor did having neither DATA keys. The above was the only thing I tried that would do the reset. More testing is probably warranted, but this should at least allow you to reset in an automation. Give that a go and see if it works for you. If you need help with the automation, post back. Cheers.

PS: I don’t know what those DATA keys are, or how they relate to zwave devices in general, but there must be something in the standards about it, e.g., what are the different meter types, etc.

1 Like

Do you have it using the long term stats so they show up in the energy section?

Hmm, I thought I tried that in Dev Tools and couldn’t get it to work. Glad you got it working.

If you are asking me, I do not. I only have these three devices that I care about at the moment, and only in originally determining their energy efficiency. So I just read the values after some time and did my calculations. I currently don’t use the Energy functionality in HA, but plan to get an energy meter for my panel some day.

Having said that, i see no reason that you could not integrate these into Energy tracking.

Thanks @GrizzlyAK
I am using a modified version of your code for both my fridge and freezer and it works great.
It’s saved me once already!

1 Like

Thank you very much for sharing your excellent project with zen15 @GrizzlyAK. I am a newbie to HA and I am trying to learn it little by little. I am trying to copy you and implement this for my HA. I would be grateful if you can share the yaml code for the Status Card utilizing Button Cards and the entities card that shows the Power used and the state of the Template Binary Sensor.

Sure, below is the YAML for the status card (just the pieces related to this post):

type: vertical-stack
title: Status
cards:
  - cards:
      - entity: switch.zooz_zen15_power_cord_fridge_us_switch
        name: Fridge US
        icon: mdi:power
        size: 30px
        state:
          - color: green
            value: 'on'
          - color: red
            value: 'off'
            styles:
              icon:
                - animation: blink 0.75s ease infinite
        styles:
          name:
            - font-size: 12px
            - color: green
        tap_action:
          action: more-info
        type: custom:button-card
      - entity: input_boolean.fridge_us_power_supply_monitor_ib
        name: Fridge US
        size: 30px
        state:
          - color: green
            icon: mdi:power-plug-outline
            value: 'off'
          - color: red
            icon: mdi:power-plug-off-outline
            value: 'on'
            styles:
              icon:
                - animation: blink 0.75s ease infinite
        styles:
          name:
            - font-size: 12px
            - color: green
        tap_action:
          action: more-info
        type: custom:button-card
      - entity: input_boolean.fridge_us_unit_monitor_ib
        name: Fridge US
        size: 30px
        state:
          - color: green
            icon: mdi:thermometer-low
            value: 'off'
          - color: red
            icon: mdi:thermometer-alert
            value: 'on'
            styles:
              icon:
                - animation: blink 0.75s ease infinite
        styles:
          name:
            - font-size: 12px
            - color: green
          icon:
            - color: |
                [[[
                  if (states['binary_sensor.fridge_us_running_monitor_bst'].state == 'on')
                    return "yellow";
                  else
                    return "green";
                ]]]
        tap_action:
          action: more-info
        type: custom:button-card
    type: horizontal-stack

Which produces the following:

image

Below is the YAML for the other card:

type: entities
entities:
  - entity: sensor.zooz_zen15_power_cord_fridge_us_power
    name: Fridge US Power
  - entity: binary_sensor.fridge_us_running_monitor_bst
    name: Fridge US Running Monitor
title: Zooz ZEN15 Power Cords
show_header_toggle: false
state_color: true

Which produces this:

image

Hope that helps. Good luck. Welcome to Home Assistant!

1 Like

Thank you very much @GrizzlyAK for sharing your code and your valued time . I really appreciate it.

1 Like

Multiple ZEN15 owner, too. They work great in places that are out-of-range for other devices and were key to stabilizing my Z-Wave network.

My favorite application is monitoring pool/pond motors. When the power consumption drops below a certain threshold (presumably due to cavitation of the impeller), I know it is time to clean the filters.

However, they have to be installed in a weatherproof enclosure. Is there an outdoor version with the same power reporting?

1 Like

Nice! just pick up another one during their sale.

The Minoston MP22ZP looks promising.

1 Like

Yeah, I have two of these Doubles from Zooz. They also have a single version. I’ve had one outside all winter with no problems, and just recently bought my second.

I have 3 Zooz Zen15 outlets. Is there a way to calibrate the Zen15 like you can the Sonoff S31 (Tasmota)?

Not sure what you mean by “calibrate”. Can you explain what you are trying to achieve?

The voltage at the outlet measured with 2 multimeters is 123.7V, but the Zen15 reports 138V.

Also, the amperage measured with two devices like Kill-A-Watt meters for a steady load is 750W, but the Zen15 is always much higher.

I have three Zen15’s, and all give different values for voltages when connected to the same outlet… so each Zen15 has their own internal calibration

If there is a direct correlation between actual measurements vs the Zen15 then it may be possible to add offsets and create my own sensors in YAML.

The Sonoff 31 and other Tasmota Power devices have calibration steps such as direct entry of Voltages, Power and Power Factor values… I was looking for something similar with the Zen15.

See the following link as an example of power monitoring calibration:
https://tasmota.github.io/docs/Power-Monitoring-Calibration/