First Alert Z-Wave Smoke / Carbon Monoxide Detectors don't show up in Home-Assistant

@aimc I took your awesome template and app and put it to work tonight. But I also added tts with it for my sonos. I did this in SmartThings with the webcore component to speak announcements for my smoke alarms. Worked great for my kiddos. I have this one setup to fire off the initial announcement and then it will repeat itself every 30 seconds as long as the condition remains. Thank you.

import appdaemon.plugins.hass.hassapi as hass

#
# App to send notification when a sensor changes state
#
# Args:
#
# sensor: sensor to monitor e.g. sensor.upstairs_smoke
# idle_state - normal state of sensor e.g. Idle
# turn_on - scene or device to activate when sensor changes e.g. scene.house_bright
# Release Notes
#
# Version 1.0:
#   Initial Version

class SensorNotification(hass.Hass):

  def initialize(self):
    if "sensor" in self.args:
      for sensor in self.split_device_list(self.args["sensor"]):
        self.listen_state(self.state_change, sensor)
    self.media_player = 'group.speakers'

  def state_change(self, entity, attribute, old, new, kwargs):
    self.log("{} is in state {}".format(self.friendly_name(entity), new))
    #self.notify("{} is in state {}".format(self.friendly_name(entity), new), name="ios")
    if new != self.args["idle_state"] and "turn_on" in self.args:
      self.turn_on(self.args["turn_on"])
    if new == "Fire":
        while new == "Fire":
            self.fire_announcement(deviceID=entity)
            self.fire_handle = self.run_in(self.fire_announcement, 30, deviceID=entity)
        else:
            self.cancel_timer(self.fire_handle)
    if new == "CO2":
        while new == "CO2":
            self.co2_announcement(deviceID=entity)
            self.co2_handle = self.run_in(self.co2_announcement, 30, deviceID=entity
        else:
            self.cancel_timer(self.fire_handle)


    def fire_announcement(self,kwargs):
        friendly_name = self.get_state(kwargs['deviceID'], attribute='friendly_name')
        message = "The {} has detected smoke.  Please exit the house immediately through the safest path." .format(friendly_name)
        self.call_service("media_player/volume_set", entity_id=self.media_player, volume_level = 100)
        self.call_service("tts/google_say", entity_id=self.media_player, message=message)

    def co2_announcement(self,kwargs):
        friendly_name = self.get_state(kwargs['deviceID'], attribute='friendly_name')
        message = "The {} has detected carbon monoxide.  Please exit the house immediately through the safest path." .format(friendly_name)
        self.call_service("media_player/volume_set", entity_id=self.media_player, volume_level = 100)
        self.call_service("tts/google_say", entity_id=self.media_player, message=message)

edit: I commented out the notify for the moment while I’m still figuring out which notification platform I want to use. I’m probably also going to do a web call with IFTTT to call my cell phone and my wifes if we’re not home.

1 Like

So I cleaned up my code a good bit for anyone who would like to use this full credit goes to @aimc since I took his and just started adding to it. It will be available from this point forward here
EDIT: Sorry moved my repo to my own internal git server. But here is the code

import appdaemon.plugins.hass.hassapi as hass
import time
import datetime

#
# App to send notification when a sensor changes state
#
# Args:
#
# sensor: sensor to monitor e.g. sensor.upstairs_smoke
# idle_state - normal state of sensor e.g. Idle
# turn_on - scene or device to activate when sensor changes e.g. scene.house_bright
# Release Notes
#
# Version 1.0:
#   Initial Version

class SensorNotification(hass.Hass):

  def initialize(self):
    if "sensor" in self.args:
      for sensor in self.args["sensor"]:
        self.listen_state(self.state_change, sensor)
    self.media_player = 'group.speakers'
    self.alexa = 'group.alexa'

  def state_change(self, entity, attribute, old, new, kwargs):
    self.log("{} is in state {}".format(self.friendly_name(entity), new))
    testing = False
    if new == "Fire":
        self.log("Announcing there is a fire")
        message_text = "The {} has detected smoke.  Please exit the house immediately through the safest path." .format(self.friendly_name(entity))

    elif new == "CO":
        self.log("Announcing there is CO")
        message_text = "The {} has detected carbon monoxide.  Please exit the house immediately through the safest path." .format(self.friendly_name(entity))

    elif new == "Testing":
        testing = True
        self.log("Announcing that we're testing")
        message_text = "The {} has detected test mode.  There is no need for you to panic this is only a test." .format(self.friendly_name(entity))

    elif new == "Idle" and old != "Idle":
        self.log("The {} has gone back to Idle".format(self.friendly_name(entity), new))
        self.cancel_timer(self.timer)

    else:
        self.log("I got an unknown state")
        return

    starttime = datetime.datetime.now() + datetime.timedelta(seconds=1)
    self.timer = self.run_every(self.announcement_cb,starttime,15, message_text=message_text,testing=testing)

  def announcement_cb(self,kwargs):
      self.call_service("media_player/volume_set", entity_id=self.media_player, volume_level = 100)
      self.call_service("tts/google_say", entity_id=self.media_player, message=kwargs["message_text"])
      self.call_service("media_player/alexa_tts", entity_id=self.alexa, message=kwargs["message_text"])
      if not kwargs["testing"]:
          self.call_service("notify/hangouts", message=kwargs["message_text"])
          self.call_service("notify/discord", message=kwargs["message_text"], target="ACCOUNTID")
          for light in self.args["turn_on"]:
              self.turn_on(light)
2 Likes

Just had a thought and wondering if anyone has tried it. Can you set the state of the other alarms to match the state of the alarm that is going off to force them to activate? Kinda like how those alarms are linked to each other so if one goes off the rest go off? Would need to do some thought into this if you can, but I’m assuming since they sleep most of the time it’d be hard to get a command to them until they woke up but hopefully by then it would be a moot point. I guess you could lower the wake up from 3600 to like 300 but that doesn’t sound like a good idea for battery life.

No, this would not work. Changing the state in HA does not change the state of the device. In order to make the smoke alarm go off the device would need to accept such a command and unfortunately it does not.

1 Like

I was given the opportunity to discover a new state for these at 6am today when one of them started chirping 5 times in a row every minute.

According to the zcombo manual, 5 chirps means End of Life. It reported as Level = 255 and Type = 14 in HA, so I’ve updated my template sensors accordingly.

I also see in the manual there is a Malfunction alert with 3 chirps every minute. Since we now know 12-14, I’m going to speculate that will report as type 15. I’ll update if it’s ever confirmed.

3 Likes