New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rfxtrx binary sensors #4218

Closed
wants to merge 21 commits into
from

Conversation

Projects
None yet
9 participants
@ypollart
Contributor

ypollart commented Nov 4, 2016

Description:
This brings a new platform "rfxtrx" in the binary sensors components. It mainly supports cheap binary sensors that can be found on some chinese web sites (motion sensors, door / window opening, doorbells...) based on the PT-2262 RF chip.

It also provides a few specific configuration options that could be ported to other binary sensor platforms.

Related issue (if applicable): N/A

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#1399

Example entry for configuration.yaml (if applicable):

# Example configuration.yaml entry
binary_sensor:
  platform: rfxtrx
  automatic_add: True
  devices:
    091300006ca2c6001080:
    name: motion_hall
    sensor_class: motion
    off_delay:
      seconds: 5
    0913000022670e013b70:
      name: window_room2
      sensor_class: opening
      data_bits: 4
      command_on: 0x0e
      command_off: 0x07

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.
@mention-bot

This comment has been minimized.

Show comment
Hide comment
@mention-bot

mention-bot Nov 4, 2016

@y-pollart, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Danielhiversen, @badele and @jacobtomlinson to be potential reviewers.

@y-pollart, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Danielhiversen, @badele and @jacobtomlinson to be potential reviewers.

Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
PLATFORM_SCHEMA = vol.Schema({
vol.Required("platform"): rfxtrx.DOMAIN,
vol.Optional(CONF_DEVICES, default={}): vol.All(dict, rfxtrx.valid_binary_sensor),

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (86 > 79 characters)
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (86 > 79 characters)
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
vol.Optional(ATTR_AUTOMATIC_ADD, default=False): cv.boolean,
}, extra=vol.ALLOW_EXTRA)
def setup_platform(hass, config, add_devices_callback, discovery_info=None):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 1: E302 expected 2 blank lines, found 1
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 1: E302 expected 2 blank lines, found 1
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
continue
if not entity[ATTR_DATABITS] is None:
_LOGGER.info("Masked device id: %s", (rfxtrx.get_pt2262_deviceid(device_id, 4)))

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (92 > 79 characters)
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (92 > 79 characters)
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
entity[ATTR_NAME], entity[ATTR_SENSOR_CLASS])
device = RfxtrxBinarySensor(event, entity[ATTR_NAME],
entity[ATTR_SENSOR_CLASS], entity[ATTR_FIREEVENT],

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (86 > 79 characters)
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (86 > 79 characters)
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
device = RfxtrxBinarySensor(event, entity[ATTR_NAME],
entity[ATTR_SENSOR_CLASS], entity[ATTR_FIREEVENT],
entity[ATTR_OFF_DELAY], entity[ATTR_DATABITS],

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (82 > 79 characters)
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (82 > 79 characters)
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
add_devices_callback(sensors)
#pylint: disable=too-many-branches

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 5: E265 block comment should start with '# '
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 5: E265 block comment should start with '# '
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
if not sensor.is_on or sensor.should_fire_event:
sensor.update_state(True)
if sensor.is_on and not sensor.off_delay is None and sensor.delay_listener is None:

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 29: E714 test for object identity should be 'is not'
  • 80: E501 line too long (91 > 79 characters)
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 29: E714 test for object identity should be 'is not'
  • 80: E501 line too long (91 > 79 characters)
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
if binary_sensor_update not in rfxtrx.RECEIVED_EVT_SUBSCRIBERS:
rfxtrx.RECEIVED_EVT_SUBSCRIBERS.append(binary_sensor_update)
#pylint: disable=too-many-instance-attributes,too-many-arguments

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 1: E265 block comment should start with '# '
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 1: E265 block comment should start with '# '
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
rfxtrx.RECEIVED_EVT_SUBSCRIBERS.append(binary_sensor_update)
#pylint: disable=too-many-instance-attributes,too-many-arguments
class RfxtrxBinarySensor(BinarySensorDevice):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 1: E302 expected 2 blank lines, found 1
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 1: E302 expected 2 blank lines, found 1
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
self._cmd_on = cmd_on
self._cmd_off = cmd_off
if not data_bits is None:

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 12: E714 test for object identity should be 'is not'
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 12: E714 test for object identity should be 'is not'
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
self._cmd_off = cmd_off
if not data_bits is None:
self._masked_id = rfxtrx.get_pt2262_deviceid(event.device.id_string.lower(), data_bits)

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (99 > 79 characters)
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (99 > 79 characters)
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
self._masked_id = None
def __str__(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 5: E303 too many blank lines (2)
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 5: E303 too many blank lines (2)
return self._name
@property
def name(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D102: Missing docstring in public method
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D102: Missing docstring in public method
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
return self._name
@property
def is_pt2262(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'd')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'd')
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
@property
def is_pt2262(self):
"""Return true if the device is PT2262-based"""
return not self._data_bits is None

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 16: E714 test for object identity should be 'is not'
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 16: E714 test for object identity should be 'is not'
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
return not self._data_bits is None
@property
def masked_id(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not ')')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not ')')
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
return self._masked_id
@property
def data_bits(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 's')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 's')
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
return self._data_bits
@property
def cmd_on(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D210: No whitespaces allowed surrounding docstring text
  • D400: First line should end with a period (not 'd')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D210: No whitespaces allowed surrounding docstring text
  • D400: First line should end with a period (not 'd')
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
return self._cmd_on
@property
def cmd_off(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D210: No whitespaces allowed surrounding docstring text
  • D400: First line should end with a period (not 'd')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D210: No whitespaces allowed surrounding docstring text
  • D400: First line should end with a period (not 'd')
return self._should_fire_event
@property
def sensor_class(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 's')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 's')
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
return self._sensor_class
@property
def off_delay(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'e')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'e')
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
return self._off_delay
@property
def is_on(self):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'e')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'e')
Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
"""Return true if the sensor state is True"""
return self._state
def apply_cmd(self, cmd):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'e')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'e')
elif cmd == self.cmd_off:
self.update_state(False)
def update_state(self, state):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'e')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 'e')
Show outdated Hide outdated homeassistant/components/rfxtrx.py
@@ -90,6 +98,9 @@ def valid_sensor(value):
"""Validate sensor configuration."""
return _valid_device(value, "sensor")
def valid_binary_sensor(value):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 1: E302 expected 2 blank lines, found 1
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 1: E302 expected 2 blank lines, found 1
Show outdated Hide outdated homeassistant/components/rfxtrx.py
vol.Optional(ATTR_NAME, default=None): cv.string,
vol.Optional(CONF_SENSOR_CLASS, default=None): cv.string,
vol.Optional(ATTR_FIREEVENT, default=False): cv.boolean,
vol.Optional(ATTR_OFF_DELAY, default=None): vol.Any(cv.time_period, cv.positive_timedelta),

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (95 > 79 characters)
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • 80: E501 line too long (95 > 79 characters)
Show outdated Hide outdated homeassistant/components/rfxtrx.py
@@ -187,6 +208,50 @@ def get_rfx_object(packetid):
obj = rfxtrxmod.ControlEvent(pkt)
return obj
def get_pt2262_deviceid(device_id, nb_data_bits):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 't')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 't')
Show outdated Hide outdated homeassistant/components/rfxtrx.py
return binascii.hexlify(data)
def get_pt2262_cmd(device_id, data_bits):

This comment has been minimized.

@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 't')
@balloobbot

balloobbot Nov 4, 2016

Contributor

farcy v1.1

  • D400: First line should end with a period (not 't')
@jacobtomlinson

This comment has been minimized.

Show comment
Hide comment
@jacobtomlinson

jacobtomlinson Nov 9, 2016

Contributor

@y-pollart I would be interested to see some sensors that work with this. Can you share some links?

Contributor

jacobtomlinson commented Nov 9, 2016

@y-pollart I would be interested to see some sensors that work with this. Can you share some links?

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 9, 2016

Contributor

Hi @jacobtomlinson
Here are some sensors I'm using at home. I've bought them on aliexpress.com and I've written this component for them:

In my experience so far, the best sensors I've found are made by the "KERUI" brand:

  • This motion sensor has jumpers to setup the tripping delay (once every 5 seconds or 5 minutes) and the LED activation. It can be powered by batteries or a micro-USB adapter.
  • So far my favourite device is this door sensor, as it sends a signal for "door opened", "door closed", and "tamper switch triggered". It may also send a signal for "low battery" but so far I've not been able to get it.
    In my config "opened" and "closed" signals are handled on the same device with "command_on" and "command_off"; whereas the tamper switch has a separate device id.

I'd be glad to share more info if you need it!

Contributor

ypollart commented Nov 9, 2016

Hi @jacobtomlinson
Here are some sensors I'm using at home. I've bought them on aliexpress.com and I've written this component for them:

In my experience so far, the best sensors I've found are made by the "KERUI" brand:

  • This motion sensor has jumpers to setup the tripping delay (once every 5 seconds or 5 minutes) and the LED activation. It can be powered by batteries or a micro-USB adapter.
  • So far my favourite device is this door sensor, as it sends a signal for "door opened", "door closed", and "tamper switch triggered". It may also send a signal for "low battery" but so far I've not been able to get it.
    In my config "opened" and "closed" signals are handled on the same device with "command_on" and "command_off"; whereas the tamper switch has a separate device id.

I'd be glad to share more info if you need it!

@jacobtomlinson

This comment has been minimized.

Show comment
Hide comment
@jacobtomlinson

jacobtomlinson Nov 9, 2016

Contributor

@y-pollart Thanks for the comprehensive response!

I've been tempted to order some Kerui stuff in the past, but wasn't sure it would work well with my rfxcom rfxtrx433e.

One device I'm really interested in is a sensor module which can be attached to any manual switch and send a signal in a similar way to a remote. This could be a good opportunity to just hack about with a door sensor and make one myself.

Contributor

jacobtomlinson commented Nov 9, 2016

@y-pollart Thanks for the comprehensive response!

I've been tempted to order some Kerui stuff in the past, but wasn't sure it would work well with my rfxcom rfxtrx433e.

One device I'm really interested in is a sensor module which can be attached to any manual switch and send a signal in a similar way to a remote. This could be a good opportunity to just hack about with a door sensor and make one myself.

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 9, 2016

Contributor

Yep, it' would be a good idea!

I'm also having a lot of ideas for using those sensors but at the moment I don't have much time.

That reminds me that I've also bought some other stuff with less success, it's also worth knowing:

  • The Linptech battery-free doorbell looks like a very good idea. It uses something like EnOcean devices. It operates in the 433 MHz frequency but the rfxcom does not even "see" the signal.
  • This door sensor uses a EV-1527 RF chip that is very similar to the PT-2262 and usually compatible. Unfortunately this one is not. The signal pulse timings are outside the rfxcom range. It only sees "undecoded ARC" packets that are too short to be meaningful. I've discussed about it with Bert Weijenberg from Rfxcom but I'm not sure it can be supported in a future firmware upgrade.
Contributor

ypollart commented Nov 9, 2016

Yep, it' would be a good idea!

I'm also having a lot of ideas for using those sensors but at the moment I don't have much time.

That reminds me that I've also bought some other stuff with less success, it's also worth knowing:

  • The Linptech battery-free doorbell looks like a very good idea. It uses something like EnOcean devices. It operates in the 433 MHz frequency but the rfxcom does not even "see" the signal.
  • This door sensor uses a EV-1527 RF chip that is very similar to the PT-2262 and usually compatible. Unfortunately this one is not. The signal pulse timings are outside the rfxcom range. It only sees "undecoded ARC" packets that are too short to be meaningful. I've discussed about it with Bert Weijenberg from Rfxcom but I'm not sure it can be supported in a future firmware upgrade.
@jacobtomlinson

This comment has been minimized.

Show comment
Hide comment
@jacobtomlinson

jacobtomlinson Nov 9, 2016

Contributor

@y-pollart Looks like Ali Express have a sale on Kerui stuff starting tomorrow.

I'll let you know how I get on.

Contributor

jacobtomlinson commented Nov 9, 2016

@y-pollart Looks like Ali Express have a sale on Kerui stuff starting tomorrow.

I'll let you know how I get on.

Show outdated Hide outdated homeassistant/components/binary_sensor/rfxtrx.py
if not entity[ATTR_DATA_BITS] is None:
_LOGGER.info("Masked device id: %s",
rfxtrx.get_pt2262_deviceid(device_id, 4))

This comment has been minimized.

@Danielhiversen

Danielhiversen Nov 9, 2016

Member

Should it be entity[ATTR_DATA_BITS] instead of 4?

@Danielhiversen

Danielhiversen Nov 9, 2016

Member

Should it be entity[ATTR_DATA_BITS] instead of 4?

This comment has been minimized.

@ypollart

ypollart Nov 9, 2016

Contributor

yes, you are right, I'll fix this asap

@ypollart

ypollart Nov 9, 2016

Contributor

yes, you are right, I'll fix this asap

@Danielhiversen

This comment has been minimized.

Show comment
Hide comment
@Danielhiversen

Danielhiversen Nov 9, 2016

Member

I think this is a very useful contribution, thanks.
I think the code looks fine, but I have not tested it.

<<data_bits (Optional): For PT-2262 based sensors, defines how many data bits are used by the device in its RF messages.>>
I think this is a bit unclear. How can I know how many bits are used by the device?
Is it possible to auto detect this?

And how do I find command_on and command_off?
Can the binary sensor print some output when a command is received?

Could you add a step-by-step example for a PT-2262 sensor to the documentation?

I also think you could add links to working devices to the documentation.

Member

Danielhiversen commented Nov 9, 2016

I think this is a very useful contribution, thanks.
I think the code looks fine, but I have not tested it.

<<data_bits (Optional): For PT-2262 based sensors, defines how many data bits are used by the device in its RF messages.>>
I think this is a bit unclear. How can I know how many bits are used by the device?
Is it possible to auto detect this?

And how do I find command_on and command_off?
Can the binary sensor print some output when a command is received?

Could you add a step-by-step example for a PT-2262 sensor to the documentation?

I also think you could add links to working devices to the documentation.

@Danielhiversen

This comment has been minimized.

Show comment
Hide comment
@Danielhiversen

Danielhiversen Nov 9, 2016

Member

@turbokongen
Do you have any sensors you can test with?

Member

Danielhiversen commented Nov 9, 2016

@turbokongen
Do you have any sensors you can test with?

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 9, 2016

Contributor

@Danielhiversen thanks for your comments.
I'll try to explain how to get the data bit size more precisely and provide some links to the devices I've bought.

I think it would be possible to automatically detect the number of bits, but the main problem is to find a way to display the info to the user.

The general idea would be:

  • Configure the component with "automatic_add" to True
  • Trigger the sensor for the "on" event (e.g. "window open") and get the corresponding device id from the logs or the UI.
  • Trigger the same sensor for the "off" event (e.g. "window closed") and get the corresponding device id.
  • Use a small script to calculate how many bits differ between the two device ids. That number is the "data_bit" configuration parameter.
  • The script would also be able to display the values to set for "command_on" and "command_off" in the configuration.

Do you think providing such a script is a good idea?

Contributor

ypollart commented Nov 9, 2016

@Danielhiversen thanks for your comments.
I'll try to explain how to get the data bit size more precisely and provide some links to the devices I've bought.

I think it would be possible to automatically detect the number of bits, but the main problem is to find a way to display the info to the user.

The general idea would be:

  • Configure the component with "automatic_add" to True
  • Trigger the sensor for the "on" event (e.g. "window open") and get the corresponding device id from the logs or the UI.
  • Trigger the same sensor for the "off" event (e.g. "window closed") and get the corresponding device id.
  • Use a small script to calculate how many bits differ between the two device ids. That number is the "data_bit" configuration parameter.
  • The script would also be able to display the values to set for "command_on" and "command_off" in the configuration.

Do you think providing such a script is a good idea?

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 9, 2016

Contributor

@jacobtomlinson the 11th of November is a national "global shopping festival" in China, like "black friday".
It was originally created as the "Singles day", a day for single people to buy presents for themselves 😃

Contributor

ypollart commented Nov 9, 2016

@jacobtomlinson the 11th of November is a national "global shopping festival" in China, like "black friday".
It was originally created as the "Singles day", a day for single people to buy presents for themselves 😃

ypollart added some commits Nov 9, 2016

@Danielhiversen

This comment has been minimized.

Show comment
Hide comment
@Danielhiversen

Danielhiversen Nov 10, 2016

Member

@y-pollart
If you can calculate the data_bit from the command_on and command_off.
Why do you need the data_bit from the config?

Member

Danielhiversen commented Nov 10, 2016

@y-pollart
If you can calculate the data_bit from the command_on and command_off.
Why do you need the data_bit from the config?

@turbokongen

This comment has been minimized.

Show comment
Hide comment
@turbokongen

turbokongen Nov 10, 2016

Member

I finally got around to test this....
I have got the Chuango PIR-700
And it seems to be working just fine with this setup:

binary_sensor:
  - platform: rfxtrx
    automatic_add: True
    devices:
      0820000d7a09b00479:
        name: 'Bevegelse i ganga'
        sensor_class: motion
        off_delay:
          seconds: 5

One note though: If you are running the Ext2 firmware this will not work, as these are decoded as X10 sensors.
The thing with these PT2262 sensor is that they don't consistently use the same packetId. Ie: my chuango sensor will during a week, have given me 6 different packetIds. But thats another story. If I remember correctly, the changes I made for the PT2262s in the rfxtrx library will correctly define the on and off commands. Might be wrong...

Member

turbokongen commented Nov 10, 2016

I finally got around to test this....
I have got the Chuango PIR-700
And it seems to be working just fine with this setup:

binary_sensor:
  - platform: rfxtrx
    automatic_add: True
    devices:
      0820000d7a09b00479:
        name: 'Bevegelse i ganga'
        sensor_class: motion
        off_delay:
          seconds: 5

One note though: If you are running the Ext2 firmware this will not work, as these are decoded as X10 sensors.
The thing with these PT2262 sensor is that they don't consistently use the same packetId. Ie: my chuango sensor will during a week, have given me 6 different packetIds. But thats another story. If I remember correctly, the changes I made for the PT2262s in the rfxtrx library will correctly define the on and off commands. Might be wrong...

@turbokongen

This comment has been minimized.

Show comment
Hide comment
@turbokongen

turbokongen Nov 10, 2016

Member

Whoopsie, Suddenly I got this:

Exception in thread Thread-7:
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/threading.py", line 911, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.4/threading.py", line 859, in run
    self._target(*self._args, **self._kwargs)
  File "/srv/hass/lib/python3.4/site-packages/RFXtrx/__init__.py", line 629, in _connect
    self._event_callback(event)
  File "/srv/hass/src/home-assistant/homeassistant/components/rfxtrx.py", line 165, in handle_receive
    subscriber(event)
  File "/srv/hass/src/home-assistant/homeassistant/components/binary_sensor/rfxtrx.py", line 114, in binary_sensor_update
    if (sensor.is_on and sensor.off_delay is not None and
AttributeError: 'RfxtrxSwitch' object has no attribute 'off_delay'

It seems to be catching my switches:

�[32m16-11-10 15:14:05 INFO (Thread-7) [homeassistant.components.rfxtrx] Receive RFXCOM event from (Device_id: 11f8f3610 Class: LightingDevice Sub: 0)�[0m
�[36m16-11-10 15:14:05 DEBUG (Thread-7) [homeassistant.components.rfxtrx] Device_id: 11f8f3610 device_update. Command: On�[0m
�[32m16-11-10 15:14:05 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: new_state=<state switch.garasjeporten=on; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:14:05.040310+01:00>, entity_id=switch.garasjeporten, old_state=<state switch.garasjeporten=off; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:02:45.183254+01:00>>�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463114560 FORWARDING <Event state_changed[L]: new_state=<state switch.garasjeporten=on; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:14:05.040310+01:00>, entity_id=switch.garasjeporten, old_state=<state switch.garasjeporten=off; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:02:45.183254+01:00>>�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463115248 FORWARDING <Event state_changed[L]: new_state=<state switch.garasjeporten=on; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:14:05.040310+01:00>, entity_id=switch.garasjeporten, old_state=<state switch.garasjeporten=off; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:02:45.183254+01:00>>�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463115456 FORWARDING <Event state_changed[L]: new_state=<state switch.garasjeporten=on; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:14:05.040310+01:00>, entity_id=switch.garasjeporten, old_state=<state switch.garasjeporten=off; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:02:45.183254+01:00>>�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463114560 WRITING data: {"time_fired": "2016-11-10T14:14:05.040369+00:00", "origin": "LOCAL", "data": {"new_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:14:05.040310+00:00", "last_changed": "2016-11-10T14:14:05.040310+00:00", "state": "on"}, "entity_id": "switch.garasjeporten", "old_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:02:45.183254+00:00", "last_changed": "2016-11-10T14:02:45.183254+00:00", "state": "off"}}, "event_type": "state_changed"}�[0m
�[32m16-11-10 15:14:05 INFO (Thread-7) [homeassistant.components.binary_sensor.rfxtrx] Binary sensor update (Device_id: 11f8f3610 Class: LightingDevice Sub: 0)�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463115248 WRITING data: {"time_fired": "2016-11-10T14:14:05.040369+00:00", "origin": "LOCAL", "data": {"new_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:14:05.040310+00:00", "last_changed": "2016-11-10T14:14:05.040310+00:00", "state": "on"}, "entity_id": "switch.garasjeporten", "old_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:02:45.183254+00:00", "last_changed": "2016-11-10T14:02:45.183254+00:00", "state": "off"}}, "event_type": "state_changed"}�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463115456 WRITING data: {"time_fired": "2016-11-10T14:14:05.040369+00:00", "origin": "LOCAL", "data": {"new_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:14:05.040310+00:00", "last_changed": "2016-11-10T14:14:05.040310+00:00", "state": "on"}, "entity_id": "switch.garasjeporten", "old_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:02:45.183254+00:00", "last_changed": "2016-11-10T14:02:45.183254+00:00", "state": "off"}}, "event_type": "state_changed"}�[0m
Exception in thread Thread-7:
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/threading.py", line 911, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.4/threading.py", line 859, in run
    self._target(*self._args, **self._kwargs)
  File "/srv/hass/lib/python3.4/site-packages/RFXtrx/__init__.py", line 629, in _connect
    self._event_callback(event)
  File "/srv/hass/src/home-assistant/homeassistant/components/rfxtrx.py", line 165, in handle_receive
    subscriber(event)
  File "/srv/hass/src/home-assistant/homeassistant/components/binary_sensor/rfxtrx.py", line 114, in binary_sensor_update
    if (sensor.is_on and sensor.off_delay is not None and
AttributeError: 'RfxtrxSwitch' object has no attribute 'off_delay'

I also tried to disabele automatic_add but same behaviour.

Member

turbokongen commented Nov 10, 2016

Whoopsie, Suddenly I got this:

Exception in thread Thread-7:
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/threading.py", line 911, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.4/threading.py", line 859, in run
    self._target(*self._args, **self._kwargs)
  File "/srv/hass/lib/python3.4/site-packages/RFXtrx/__init__.py", line 629, in _connect
    self._event_callback(event)
  File "/srv/hass/src/home-assistant/homeassistant/components/rfxtrx.py", line 165, in handle_receive
    subscriber(event)
  File "/srv/hass/src/home-assistant/homeassistant/components/binary_sensor/rfxtrx.py", line 114, in binary_sensor_update
    if (sensor.is_on and sensor.off_delay is not None and
AttributeError: 'RfxtrxSwitch' object has no attribute 'off_delay'

It seems to be catching my switches:

�[32m16-11-10 15:14:05 INFO (Thread-7) [homeassistant.components.rfxtrx] Receive RFXCOM event from (Device_id: 11f8f3610 Class: LightingDevice Sub: 0)�[0m
�[36m16-11-10 15:14:05 DEBUG (Thread-7) [homeassistant.components.rfxtrx] Device_id: 11f8f3610 device_update. Command: On�[0m
�[32m16-11-10 15:14:05 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: new_state=<state switch.garasjeporten=on; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:14:05.040310+01:00>, entity_id=switch.garasjeporten, old_state=<state switch.garasjeporten=off; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:02:45.183254+01:00>>�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463114560 FORWARDING <Event state_changed[L]: new_state=<state switch.garasjeporten=on; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:14:05.040310+01:00>, entity_id=switch.garasjeporten, old_state=<state switch.garasjeporten=off; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:02:45.183254+01:00>>�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463115248 FORWARDING <Event state_changed[L]: new_state=<state switch.garasjeporten=on; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:14:05.040310+01:00>, entity_id=switch.garasjeporten, old_state=<state switch.garasjeporten=off; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:02:45.183254+01:00>>�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463115456 FORWARDING <Event state_changed[L]: new_state=<state switch.garasjeporten=on; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:14:05.040310+01:00>, entity_id=switch.garasjeporten, old_state=<state switch.garasjeporten=off; assumed_state=True, friendly_name=Garasjeporten, hidden=True @ 2016-11-10T15:02:45.183254+01:00>>�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463114560 WRITING data: {"time_fired": "2016-11-10T14:14:05.040369+00:00", "origin": "LOCAL", "data": {"new_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:14:05.040310+00:00", "last_changed": "2016-11-10T14:14:05.040310+00:00", "state": "on"}, "entity_id": "switch.garasjeporten", "old_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:02:45.183254+00:00", "last_changed": "2016-11-10T14:02:45.183254+00:00", "state": "off"}}, "event_type": "state_changed"}�[0m
�[32m16-11-10 15:14:05 INFO (Thread-7) [homeassistant.components.binary_sensor.rfxtrx] Binary sensor update (Device_id: 11f8f3610 Class: LightingDevice Sub: 0)�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463115248 WRITING data: {"time_fired": "2016-11-10T14:14:05.040369+00:00", "origin": "LOCAL", "data": {"new_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:14:05.040310+00:00", "last_changed": "2016-11-10T14:14:05.040310+00:00", "state": "on"}, "entity_id": "switch.garasjeporten", "old_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:02:45.183254+00:00", "last_changed": "2016-11-10T14:02:45.183254+00:00", "state": "off"}}, "event_type": "state_changed"}�[0m
�[36m16-11-10 15:14:05 DEBUG (MainThread) [homeassistant.components.api] STREAM 140423463115456 WRITING data: {"time_fired": "2016-11-10T14:14:05.040369+00:00", "origin": "LOCAL", "data": {"new_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:14:05.040310+00:00", "last_changed": "2016-11-10T14:14:05.040310+00:00", "state": "on"}, "entity_id": "switch.garasjeporten", "old_state": {"attributes": {"assumed_state": true, "friendly_name": "Garasjeporten", "hidden": true}, "entity_id": "switch.garasjeporten", "last_updated": "2016-11-10T14:02:45.183254+00:00", "last_changed": "2016-11-10T14:02:45.183254+00:00", "state": "off"}}, "event_type": "state_changed"}�[0m
Exception in thread Thread-7:
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/threading.py", line 911, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.4/threading.py", line 859, in run
    self._target(*self._args, **self._kwargs)
  File "/srv/hass/lib/python3.4/site-packages/RFXtrx/__init__.py", line 629, in _connect
    self._event_callback(event)
  File "/srv/hass/src/home-assistant/homeassistant/components/rfxtrx.py", line 165, in handle_receive
    subscriber(event)
  File "/srv/hass/src/home-assistant/homeassistant/components/binary_sensor/rfxtrx.py", line 114, in binary_sensor_update
    if (sensor.is_on and sensor.off_delay is not None and
AttributeError: 'RfxtrxSwitch' object has no attribute 'off_delay'

I also tried to disabele automatic_add but same behaviour.

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 10, 2016

Contributor

Hi everyone, thanks for your feedback. First, sorry I'm not able to answer as soon as I'd like.

@Danielhiversen I'll look at the "data_bit" and "command_on/command_off" and try to think of a good solution.

@turbokongen as I only have tested my devices as Lighting4, I didn't know they were seen as X10 under a different firmware. I'll have a look at it.

So from your logs your device is recognized as an rfxtrx switch, but your configuration says it's a binary sensor. Is "automatic_add" enabled at the same time for the rfxtrx switch and rfxtrx binary sensor?
That may explain the conflict. Try to completely disable "automatic_add".

I'll try this with an ext2 firmware and see if I can reproduce the problem.

Contributor

ypollart commented Nov 10, 2016

Hi everyone, thanks for your feedback. First, sorry I'm not able to answer as soon as I'd like.

@Danielhiversen I'll look at the "data_bit" and "command_on/command_off" and try to think of a good solution.

@turbokongen as I only have tested my devices as Lighting4, I didn't know they were seen as X10 under a different firmware. I'll have a look at it.

So from your logs your device is recognized as an rfxtrx switch, but your configuration says it's a binary sensor. Is "automatic_add" enabled at the same time for the rfxtrx switch and rfxtrx binary sensor?
That may explain the conflict. Try to completely disable "automatic_add".

I'll try this with an ext2 firmware and see if I can reproduce the problem.

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 10, 2016

Contributor

@turbokongen sorry I've not read the logs correctly, my phone screen is too small... So your rfxtrx switches are being intercepted by the binary sensor component.

I think I know where to look. I'll get back here when I can reach my Raspberry.

Contributor

ypollart commented Nov 10, 2016

@turbokongen sorry I've not read the logs correctly, my phone screen is too small... So your rfxtrx switches are being intercepted by the binary sensor component.

I think I know where to look. I'll get back here when I can reach my Raspberry.

@Danielhiversen

This comment has been minimized.

Show comment
Hide comment
Member

Danielhiversen commented Nov 10, 2016

Is it possible to use event.values['Command'] to recognize a command?
https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/components/rfxtrx.py#L273

@turbokongen

This comment has been minimized.

Show comment
Hide comment
@turbokongen

turbokongen Nov 10, 2016

Member

@y-pollart yes, correct. The configured sensor works just fine. It's when a switch transmits that the binary_sensor platform intercepts the command.

Member

turbokongen commented Nov 10, 2016

@y-pollart yes, correct. The configured sensor works just fine. It's when a switch transmits that the binary_sensor platform intercepts the command.

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 11, 2016

Contributor

@turbokongen can you give the latest update a try? Now the update callback does nothing if the triggered device is not a binary sensor.

@Danielhiversen event.values['Command'] are defined in the rfxtrx platform. It means that all the "on" and "off" command codes are the same for every sensor. Unfortunately that's not how pt-2262 devices work because there is actually no standard meaning for the data bits values.

One of my motion sensors uses data bits value that matches the "Off" command in rfxtrx platform and there is no way to change this value. That's why I think we should be able to specify the "on" and "off" values for each device.

I have a few ideas on how to get the "command_on", "command_off" and "data_bits" attributes in a simple way. I'll be experimenting them and I'll get back when I find something!

Contributor

ypollart commented Nov 11, 2016

@turbokongen can you give the latest update a try? Now the update callback does nothing if the triggered device is not a binary sensor.

@Danielhiversen event.values['Command'] are defined in the rfxtrx platform. It means that all the "on" and "off" command codes are the same for every sensor. Unfortunately that's not how pt-2262 devices work because there is actually no standard meaning for the data bits values.

One of my motion sensors uses data bits value that matches the "Off" command in rfxtrx platform and there is no way to change this value. That's why I think we should be able to specify the "on" and "off" values for each device.

I have a few ideas on how to get the "command_on", "command_off" and "data_bits" attributes in a simple way. I'll be experimenting them and I'll get back when I find something!

@turbokongen

This comment has been minimized.

Show comment
Hide comment
@turbokongen

turbokongen Nov 11, 2016

Member

Yes, got to test this now.
Now it works as expected.
I also just did a quick test with one of my door switches(Nexa magnetic contact) And defined it as a binary_sensor, and behold, it works just like the chuango.
That means any switch can be defined as a binary sensor?

Member

turbokongen commented Nov 11, 2016

Yes, got to test this now.
Now it works as expected.
I also just did a quick test with one of my door switches(Nexa magnetic contact) And defined it as a binary_sensor, and behold, it works just like the chuango.
That means any switch can be defined as a binary sensor?

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 11, 2016

Contributor

Yes. As a binary sensor has only "on" and "off" states, it's technically
exactly the same as a plain switch.

To me they differ by their use (e.g. a motion sensor should not be
considered as a switch) and the binary sensor class is more suitable for
devices that are "not just dumb push-button switches" as their state have
meanings directly mapped in Hass by the "sensor_class" attribute.

It's only my personal point of view, of course!

And I forgot: some sensors have more than "on/off" signals. The Kerui door sensor I've talked about earlier sends signals for "open", "close", "tamper switch triggered" and maybe also "battery low".
In Hass I've configured this sensor with 2 devices:

  • one binary sensor for the "open/close" events
  • and another binary sensor as a" safety" sensor_class for the tampering switch. I could have used a switch for that one but Hass displays a nice icon without needing any customisation 😄
Contributor

ypollart commented Nov 11, 2016

Yes. As a binary sensor has only "on" and "off" states, it's technically
exactly the same as a plain switch.

To me they differ by their use (e.g. a motion sensor should not be
considered as a switch) and the binary sensor class is more suitable for
devices that are "not just dumb push-button switches" as their state have
meanings directly mapped in Hass by the "sensor_class" attribute.

It's only my personal point of view, of course!

And I forgot: some sensors have more than "on/off" signals. The Kerui door sensor I've talked about earlier sends signals for "open", "close", "tamper switch triggered" and maybe also "battery low".
In Hass I've configured this sensor with 2 devices:

  • one binary sensor for the "open/close" events
  • and another binary sensor as a" safety" sensor_class for the tampering switch. I could have used a switch for that one but Hass displays a nice icon without needing any customisation 😄
@turbokongen

This comment has been minimized.

Show comment
Hide comment
@turbokongen

turbokongen Nov 12, 2016

Member

Maybe a change in the pyrfxtrx lib is in order, to define those on, off, tamper, open, close signals.
That is if there is a way to differentiate between them?
I made the code for rfxtrx library from what I could find by googleling :)

Member

turbokongen commented Nov 12, 2016

Maybe a change in the pyrfxtrx lib is in order, to define those on, off, tamper, open, close signals.
That is if there is a way to differentiate between them?
I made the code for rfxtrx library from what I could find by googleling :)

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 12, 2016

Contributor

Well actually I don't think we should change that. It would be cumbersome to manage all those signals in the same class. Having both switches and binary sensor classes makes sense to me (otherwise we could question the existence of the whole binary sensor component in Hass 😅), and managing the tampering switch as a separate device makes sense to me as well.

I started to play with rfxtrx components because my cheap devices were not supported the way I wanted, mainly because of the PT-2262 "on" and "off" commands.
At first I wanted my binary sensor class to inherit from both BinarySensorDevice and RfxtrxSwitch but I could not get it to work (especially with the way I PT-2262 device ids must be looked-up in the device dictionary). That's why I decided to take the same path as the RfxtrxSensor class, which does a lot of things by itself.

I do think that RfxtrxSwitch and RfxtrxBinarySensor classes should share more code (having swiches with the "off_delay" feature would be nice, ideally the PT-2262 attributes and lookup method should be integrated in switches too).

Maybe we can get to something like: an RfxtrxBinarySensor is a BinarySensorDevice that has one RfxtrxSwitch and other specific attributes.

That's just my two cents. I'd be glad to hear everyone's thought on this 😄

Contributor

ypollart commented Nov 12, 2016

Well actually I don't think we should change that. It would be cumbersome to manage all those signals in the same class. Having both switches and binary sensor classes makes sense to me (otherwise we could question the existence of the whole binary sensor component in Hass 😅), and managing the tampering switch as a separate device makes sense to me as well.

I started to play with rfxtrx components because my cheap devices were not supported the way I wanted, mainly because of the PT-2262 "on" and "off" commands.
At first I wanted my binary sensor class to inherit from both BinarySensorDevice and RfxtrxSwitch but I could not get it to work (especially with the way I PT-2262 device ids must be looked-up in the device dictionary). That's why I decided to take the same path as the RfxtrxSensor class, which does a lot of things by itself.

I do think that RfxtrxSwitch and RfxtrxBinarySensor classes should share more code (having swiches with the "off_delay" feature would be nice, ideally the PT-2262 attributes and lookup method should be integrated in switches too).

Maybe we can get to something like: an RfxtrxBinarySensor is a BinarySensorDevice that has one RfxtrxSwitch and other specific attributes.

That's just my two cents. I'd be glad to hear everyone's thought on this 😄

@Danielhiversen

This comment has been minimized.

Show comment
Hide comment
@Danielhiversen

Danielhiversen Nov 12, 2016

Member

I agree that it RfxtrxSwitch and RfxtrxBinarySensor classes should share more code, but I think we should leave that for a later pull request.
If you have a way to simplify the data_bits part, I think you should add that. Then I think this is ready to merge.

Member

Danielhiversen commented Nov 12, 2016

I agree that it RfxtrxSwitch and RfxtrxBinarySensor classes should share more code, but I think we should leave that for a later pull request.
If you have a way to simplify the data_bits part, I think you should add that. Then I think this is ready to merge.

@Danielhiversen

This comment has been minimized.

Show comment
Hide comment
@Danielhiversen

Danielhiversen Nov 21, 2016

Member

@y-pollart : Any progress on this?

Member

Danielhiversen commented Nov 21, 2016

@y-pollart : Any progress on this?

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Nov 21, 2016

Contributor

Hi, I am sorry I'm currently having some personal matters I must take care
of. I have not been able to make any significant update for now :(

I should be able to spend more time on the code at the end of this week.

Le 21 nov. 2016 1:31 PM, "Daniel Høyer Iversen" notifications@github.com
a écrit :

@y-pollart https://github.com/y-pollart : Any progress on this?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#4218 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQoeSlaJjPT4yfK-HzFPQqyepTiXnEe6ks5rAY8PgaJpZM4KqC_Y
.

Contributor

ypollart commented Nov 21, 2016

Hi, I am sorry I'm currently having some personal matters I must take care
of. I have not been able to make any significant update for now :(

I should be able to spend more time on the code at the end of this week.

Le 21 nov. 2016 1:31 PM, "Daniel Høyer Iversen" notifications@github.com
a écrit :

@y-pollart https://github.com/y-pollart : Any progress on this?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#4218 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AQoeSlaJjPT4yfK-HzFPQqyepTiXnEe6ks5rAY8PgaJpZM4KqC_Y
.

@Danielhiversen

This comment has been minimized.

Show comment
Hide comment
@Danielhiversen

Danielhiversen Nov 21, 2016

Member

Ok, no worry. Take care.

Member

Danielhiversen commented Nov 21, 2016

Ok, no worry. Take care.

@balloob

This comment has been minimized.

Show comment
Hide comment
@balloob

balloob Dec 27, 2016

Member

This PR seems to have gone stale. Closing it. You can reopen it when you're ready to finish it.

Member

balloob commented Dec 27, 2016

This PR seems to have gone stale. Closing it. You can reopen it when you're ready to finish it.

@balloob balloob closed this Dec 27, 2016

@pixeye33

This comment has been minimized.

Show comment
Hide comment
@pixeye33

pixeye33 Feb 23, 2017

Hai there,

I'm using this code by replacing the components (in custom_components it doesn't work).
It works just fine. even with 0.38...
but i'm afraid it won't work in the future (plus i'm not getting improvements)

@ypollart i hope you can finish this change :)
or maybe someone else could finish the process ? maybe @Danielhiversen ?

pixeye33 commented Feb 23, 2017

Hai there,

I'm using this code by replacing the components (in custom_components it doesn't work).
It works just fine. even with 0.38...
but i'm afraid it won't work in the future (plus i'm not getting improvements)

@ypollart i hope you can finish this change :)
or maybe someone else could finish the process ? maybe @Danielhiversen ?

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Feb 23, 2017

Contributor
Contributor

ypollart commented Feb 23, 2017

@medolino2009

This comment has been minimized.

Show comment
Hide comment
@medolino2009

medolino2009 Feb 27, 2017

Hi all... i am glad to see support for PT-2262 is here... thank you for that...i used to use Pimatic and Domoticz, but they are both not stable enough and they are not working wel with RFXCOM... so i tried Home Assistant and here i am...

I am having trouble with PT-2262 switch (i bought one receiver switch on aliexpress)... on domoticz i could make dummy switch with right protocol (lighting4 and lighting1 i thnk) and it would work...

I am trying to do the same with support of binaryrfx but not sure where to begin... i am new to home assistant....

can anyone please make steps how shuld i install binary rfx component and how to make dummy switch using it ?

Thank you in advance

Best regards

Miki

P.S. this is switch i bought:

http://www.ebay.com/itm/272385814721?_trksid=p2057872.m2749.l2649&var=571321223670&ssPageName=STRK%3AMEBIDX%3AIT

medolino2009 commented Feb 27, 2017

Hi all... i am glad to see support for PT-2262 is here... thank you for that...i used to use Pimatic and Domoticz, but they are both not stable enough and they are not working wel with RFXCOM... so i tried Home Assistant and here i am...

I am having trouble with PT-2262 switch (i bought one receiver switch on aliexpress)... on domoticz i could make dummy switch with right protocol (lighting4 and lighting1 i thnk) and it would work...

I am trying to do the same with support of binaryrfx but not sure where to begin... i am new to home assistant....

can anyone please make steps how shuld i install binary rfx component and how to make dummy switch using it ?

Thank you in advance

Best regards

Miki

P.S. this is switch i bought:

http://www.ebay.com/itm/272385814721?_trksid=p2057872.m2749.l2649&var=571321223670&ssPageName=STRK%3AMEBIDX%3AIT

@ypollart

This comment has been minimized.

Show comment
Hide comment
@ypollart

ypollart Feb 27, 2017

Contributor

Hi everyone!
I've finally managed to get some basic updates!
Basic config information about data_bits are now written in the log in "automatic_add" mode. I'll open a new PR tomorrow and I'll try to write some more doc.

Best regards,
Yannick.

Contributor

ypollart commented Feb 27, 2017

Hi everyone!
I've finally managed to get some basic updates!
Basic config information about data_bits are now written in the log in "automatic_add" mode. I'll open a new PR tomorrow and I'll try to write some more doc.

Best regards,
Yannick.

@home-assistant home-assistant locked and limited conversation to collaborators Jun 2, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.