Yale Smart Alarm Sensors

Would be very interested in this too, I have spent an hour or two looking at this and trying to pick apart the code and looking at other components that return sensors. However, given that I know no Python whatsoever I have concluded that I am completely out of my depth!! :rofl:

With my incredibly limited knowledge it looks like it should be possible, but I just don’t have the skills or knowledge to do it sadly. It looks like the door sensor info was added to the Yale python client in February of this year, which is way after the original Yale HA component was created. Hoping someone might be able to help with this as it would be great to utilize my existing door sensors!

@mattius
Have you had any luck with this?

Afraid not, i have been snowed under with work otherwise i would have given it a bash.

So im finally getting on with this, in theory (i don’t have a dev environment for homeassistant)

I haven’t tested it yet, i still need to try it and get it setup on my system

I think this should be a custom component which will add the doors,

"""Component for interacting with the Yale Smart Alarm System API."""
import logging

import voluptuous as vol
from yalesmartalarmclient.client import (
    YALE_STATE_ARM_FULL,
    YALE_STATE_ARM_PARTIAL,
    YALE_STATE_DISARM,
    AuthenticationError,
    YaleSmartAlarmClient,
    YALE_DOOR_CONTACT_STATE_CLOSED,
    YALE_DOOR_CONTACT_STATE_OPEN,
    YALE_DOOR_CONTACT_STATE_UNKNOWN,
)

from homeassistant.components.binary_sensor import BinarySensorEntity


from homeassistant.const import (
    CONF_NAME,
    CONF_PASSWORD,
    CONF_USERNAME,
)
import homeassistant.helpers.config_validation as cv

CONF_AREA_ID = "area_id"

DEFAULT_NAME = "Yale Smart Alarm"

DEFAULT_AREA_ID = "1"

_LOGGER = logging.getLogger(__name__)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
    {
        vol.Required(CONF_USERNAME): cv.string,
        vol.Required(CONF_PASSWORD): cv.string,
        vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
        vol.Optional(CONF_AREA_ID, default=DEFAULT_AREA_ID): cv.string,
    }
)


def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the alarm platform."""
    name = config[CONF_NAME]
    username = config[CONF_USERNAME]
    password = config[CONF_PASSWORD]
    area_id = config[CONF_AREA_ID]

    try:
        client = YaleSmartAlarmClient(username, password, area_id)
    except AuthenticationError:
        _LOGGER.error("Authentication failed. Check credentials")
        return

    doors = client.get_doors_status()

    add_devices([YaleBinarySensor(d, client, doors)
                 for d in doors])

class YaleBinarySensor(Entity):
    """Implementation of a Yale binary sensor."""
    
    def __init__(self, device_name, client, yale_object):
        """Initialize the sensor."""
        self.device_name = device_name
        self.client = client
        self.yale_object = yale_object
        
    @property
    def name(self):
        """Return the name of the sensor."""
        return self.device_name
        
    @property
    def state(self):
        """Return the state of the sensor."""
        if self.yale_object[self.device_name] == "closed":
            return STATE_ON
        else:
            return STATE_OFF

    @Throttle(MIN_TIME_BETWEEN_UPDATES)
    def update(self):
        """Update sensor data."""
        self.yale_object = self.client.get_doors_status()
    

I’d love for someone who knows what they are doing to comment on it,

So the Yale Client (v. 0.1.7 , homeassistant currently has 0.1.6 for the alarm control panel)

Implements get_doors_status() which returns a dictionary of door and window sensors, in the format

{'Back Door': 'closed', 'Bathroom Window': 'closed', 'Front Door': 'closed', 'Kitchen Window': 'closed'}

So im basically looping that dictionary to create the binary sensors, and then the sensors themselves update their own copy of the dictionary and for state, look for their name as the key and compare the value.

I may be totally off, but it looks close

Can anyone who knows home assistant development help??

I just get an error No setup function defined.

Where is the best place to get help with development?

For those interested, i now have this working and have binary sensors for all my door and window contacts:

1 Like

Great work I’ll be installing this later :+1:

No probs, i did look at the PIR sensors as well, but they only respond when the alarm is set or walk mode is enabled, so kinda pointless

Great work on this. I was about to look at doing something similar. It’s a shame about the PIR sensors though as that what I really wanted unfortunately. Agreed there’s not much point if the alarm has to be set!

I can understand, saving power etc,

Im gonna re-do it in a bit to pull all possible information, im pretty sure the PIRs will notify which one triggered the alarm should it go off and notify when they go faulty.

Just need to switch from the standard python library functions and play with the raw data.

Added a new test file, binary_sensor(NEW).py to the Github,

Using the raw data now, and showing every device on the system (and some attributes)

Devices also show the tamper state, so if they are in tamper state they show tamper.

Not really seeing much from the keypad, PIRs or siren, basically all i can get from them is the tamper alert.

Be interesting to see if any state is seen when the alarm is triggered by a PIR or somthing

Just wanted to say THANK YOU!!! I’ve been waiting for ages to be able to see all my yale sensors - cracking piece of work!

I have three smoke alarms on my system and what I really hate is that if one (or more of them) go off, like today, the Yale (cr)app sends me a silent notification!!

So I’d really like to set up HA / node-red to send me a really loud notification if they go off.

At the moment they are coming into HA as binary sensors but status is set to “”. I’ve had a quick look through the py file and can see that there is no provision for smoke alarms.

Anyone got any ideas as to the status it will report when activated? I suppose I could always set one off and see - but they are bloody loud.

Any help would be appreciated. And again, thank you for doing this. Makes a pretty useless integration a fab one.

Yeah sure, i can help, i don’t actually have the smoke alarms, but i can help you help me implement them as well.

I just hope they are not like the PIRs which don’t seem to report status the same way.

What to do is add the following line in to the .py file, just below where temp_object is populated:

_LOGGER.error(str(temp_object))

So it looks like this:

        """Update sensor data."""
        temp_object = self.client._get_authenticated(_ENDPOINT_DEVICES_STATUS)
        
        _LOGGER.error(str(temp_object))
        
        for object in temp_object['data']:

Then restart your homeassistant, what this will do is dump the YALE API payload to your homeassistant logs each time it updates ( it will spam your logs ).

Then you will need to trigger a smoke alarm, and look through the log entries to see what the YALE API reports in its status, status1 and status2 fields.

If you can post the whole log entry or just what its reporting in status fields when triggered i should be able to add it.

Thanks! It’s a little late for setting of smoke alarm tonight (it already went off twice today - bloody cooker!) so will try out tomorrow and report back. Brilliant. Thanks again.

Hi there. Well, I set the logger running then I triggered smoke alarm (bloody noisy, bit I guess that’s the idea! Not sure the neighbours enjoyed it!) and when I compared the logs for the smoke alarm entity there appeared to be no difference (see below).

Do I have to wait longer than a few seconds (10) to see the updated status? I noticed the MIN_TIME_BETWEEN_UPDATES is set to 30 sec? I’m loath to do it for over 30 seconds unless that’s the answer!! Sorry to be unsure.

Log entry when idle

{‘area’: ‘1’, ‘no’: ‘14’, ‘rf’: None, ‘address’: ‘RF:e1610040’, ‘type’: ‘device_type.smoke_detector’, ‘name’: ‘Ground floor smoke’, ‘status1’: ‘’, ‘status2’: None, ‘status_switch’: None, ‘status_power’: None, ‘status_temp’: None, ‘status_humi’: None, ‘status_dim_level’: None, ‘status_lux’: ‘’, ‘status_hue’: None, ‘status_saturation’: None, ‘rssi’: ‘9’, ‘mac’: ‘00:1d:94:0a:f9:00’, ‘scene_trigger’: ‘0’, ‘status_total_energy’: None, ‘device_id2’: ‘’, ‘extension’: None, ‘minigw_protocol’: ‘’, ‘minigw_syncing’: ‘’, ‘minigw_configuration_data’: ‘’, ‘minigw_product_data’: ‘’, ‘minigw_lock_status’: ‘’, ‘minigw_number_of_credentials_supported’: ‘’, ‘sresp_button_3’: None, ‘sresp_button_1’: None, ‘sresp_button_2’: None, ‘sresp_button_4’: None, ‘ipcam_trigger_by_zone1’: None, ‘ipcam_trigger_by_zone2’: None, ‘ipcam_trigger_by_zone3’: None, ‘ipcam_trigger_by_zone4’: None, ‘scene_restore’: None, ‘thermo_mode’: None, ‘thermo_setpoint’: None, ‘thermo_c_setpoint’: None, ‘thermo_setpoint_away’: None, ‘thermo_c_setpoint_away’: None, ‘thermo_fan_mode’: None, ‘thermo_schd_setting’: None, ‘group_id’: None, ‘group_name’: None, ‘bypass’: ‘0’, ‘device_id’: ‘RF:e1610040’, ‘status_temp_format’: ‘C’, ‘type_no’: ‘11’, ‘device_group’: ‘000’, ‘status_fault’: [], ‘status_open’: [], ‘trigger_by_zone’: []},

Log entry when triggered

{‘area’: ‘1’, ‘no’: ‘14’, ‘rf’: None, ‘address’: ‘RF:e1610040’, ‘type’: ‘device_type.smoke_detector’, ‘name’: ‘Ground floor smoke’, ‘status1’: ‘’, ‘status2’: None, ‘status_switch’: None, ‘status_power’: None, ‘status_temp’: None, ‘status_humi’: None, ‘status_dim_level’: None, ‘status_lux’: ‘’, ‘status_hue’: None, ‘status_saturation’: None, ‘rssi’: ‘9’, ‘mac’: ‘00:1d:94:0a:f9:00’, ‘scene_trigger’: ‘0’, ‘status_total_energy’: None, ‘device_id2’: ‘’, ‘extension’: None, ‘minigw_protocol’: ‘’, ‘minigw_syncing’: ‘’, ‘minigw_configuration_data’: ‘’, ‘minigw_product_data’: ‘’, ‘minigw_lock_status’: ‘’, ‘minigw_number_of_credentials_supported’: ‘’, ‘sresp_button_3’: None, ‘sresp_button_1’: None, ‘sresp_button_2’: None, ‘sresp_button_4’: None, ‘ipcam_trigger_by_zone1’: None, ‘ipcam_trigger_by_zone2’: None, ‘ipcam_trigger_by_zone3’: None, ‘ipcam_trigger_by_zone4’: None, ‘scene_restore’: None, ‘thermo_mode’: None, ‘thermo_setpoint’: None, ‘thermo_c_setpoint’: None, ‘thermo_setpoint_away’: None, ‘thermo_c_setpoint_away’: None, ‘thermo_fan_mode’: None, ‘thermo_schd_setting’: None, ‘group_id’: None, ‘group_name’: None, ‘bypass’: ‘0’, ‘device_id’: ‘RF:e1610040’, ‘status_temp_format’: ‘C’, ‘type_no’: ‘11’, ‘device_group’: ‘000’, ‘status_fault’: [], ‘status_open’: [], ‘trigger_by_zone’: []},

Hey sorry i have been working away all week.

You can try changing the MIN_TIME_BETWEEN_UPDATES to something faster, 5 seconds for example,

tbh it looks like the PIR sensors response, which don’t seem to be poll able in the API.

I’ve not given up hope on them, but just not had a chance to try and reverse engineer the protocol

Hi
Just wanted to check what the latest is with interfacing with the Yale Smart home alarms? I have a Yale IA-320. I’m hoping to be able to:

  • access sensor status (i.e. doors and pir sensors)
  • arm/disarm alarm
  • activate alarm (i.e. make it sound)

Many thanks for your work on this!
Adam

The standard integration will give you the ability to arm and disarm,

My custom integration here: https://community.home-assistant.io/t/yale-smart-alarm-binary-sensors will give you the door sensors,

However there is no ability to access the PIR sensors (probably never happen due to the design of the alarm) and you cannot activate the alarm currently

Ok thanks again!
Adam

I’ve noticed the original yale smart github has been updated to trigger the alarm via panic button

I just don’t think it’s been pushed to HA