Welcome to Cowlug


Site Navigation

Home Assistant component development

This is my attempt to document the development of a component and binary_sensor platform, for the Home Assistant project.

This is the code you should use to meet requirements to get accepted into HA. I wrote a previous article with code that worked but didn't meet the requirements.

The component file:
/home/ha/home-assistant/homeassistant/components/w800rf32.py
W800rf32 component code

The component breakdown and description

The binary sensor platform file:
/home/ha/home-assistant/homeassistant/components/binary_sensor/w800rf32.py
W800rf32 binary_sensor platform code

The binary sensor breakdown and description

The switch platform file:

The Switch platform can no longer be accepted into HA, Switches must be read/write entities. Since the W800rf32 is a read only device we are not allowed to use it as a Switch, only a Binary_sensor. It's too bad because it is simple to use in the configuration.yaml. Instead of this:

  switch:
    - platform: w800rf32
    devices:
      c2:
        name: kitchen_keypad
  
We have to resort to this and the switch on the web interface doesn't keep state.
switch:
  - platform: template
    switches:
      kitchen_pad1:
        value_template: "{{ is_state('binary_sensor.kitchen_motion', 'on') }}"
        turn_on:
          service: switch.turn_on
          data:
            entity_id: switch.kitchen_pad1_on
        turn_off:
          service: switch.turn_off
          data:
            entity_id: switch.kitchen_pad1_off

If you really want to use a read only switches like I do, so you can use this:

switch:
  - platform: w800rf32
    devices:
      c2:
        name: kitchen_keypad
in your configuration.yaml, here is the unoffical switch code.