How to handle multiple endpoints in Homeassistant

I have an iCasa Remote Control RM11S. I have added entries in device.js to support it.

When I press a button, I get the following z2m output:

Aug 18 13:01:57 zacate npm[467130]: Zigbee2MQTT:debug 2020-08-18 13:01:57: Received Zigbee message from ‘0xccccccfffe26a33a’, type ‘commandOn’, cluster ‘genOnOff’, data ‘{}’ from endpoint 2 with groupID 26370
Aug 18 13:01:57 zacate npm[467130]: Zigbee2MQTT:info 2020-08-18 13:01:57: MQTT publish: topic ‘zigbee2mqtt/0xccccccfffe26a33a’, payload ‘{“action”:“on”,“action_group”:26370,“battery”:43.5,“click”:“on”,“linkquality”:2}’
Aug 18 13:01:57 zacate npm[467130]: Zigbee2MQTT:info 2020-08-18 13:01:57: MQTT publish: topic ‘zigbee2mqtt/0xccccccfffe26a33a’, payload ‘{“action”:"",“battery”:43.5,“linkquality”:2}’
Aug 18 13:01:57 zacate npm[467130]: Zigbee2MQTT:info 2020-08-18 13:01:57: MQTT publish: topic ‘zigbee2mqtt/0xccccccfffe26a33a/action’, payload ‘on’

Depending on which of the 4 channels I use, the action_group is 26369, 26370, 26371 or 26372. Pressing the master-off button actually generates the 4 messages at once.

What is the best way to represent this device in Homeassistant ?

I’m thinking of using the sensorEndpoint function, but:
1/ I have no idea whether the action_group values stay the same or how I could set them.
2/ contrary to other devices which probably have state_1, state_2, etc… (i.e. endpoint no. in the property name) the endpoint here is defined by an accompanying property.

Thanks.

Perhaps for better understanding, endpoints 1…4 correspond to the action_groups 26369…26372.

I think on a logical point of view that you need the driver map your endpoint with 1/2/3/4 at appairing time to have uniformity if you use several similar devices.
IMHO since it’s connected to zigbee2mqtt code you have to open an issue on zigbee2mqtt github project.

>

I think on a logical point of view that you need the driver map your endpoint with 1/2/3/4 at appairing time to have uniformity if you use several similar devices.

I also think there should be a provision for composite devices, i.e. physical devices that are effectively a group of logical ones. You could then use the Home Assistant entity mapping very effectively.

On the other hand, there is also an advantage to the simple concept of one thing = one entity.

IMHO since it’s connected to zigbee2mqtt code you have to open an issue on zigbee2mqtt github project.

This is the zigbee2mqtt forum, is it not ? I discussed it here because it is not, strictly speaking, a bug.

It’s not a bug but it’s almost a new integration for a specific kind of device and usually Koenkk is really reactive to this kind of topic on github.

In actual state, you can use these attributes to use it in home assistant and you can create your own input_boolean based on “action” and “action_group” attributes if you have only one entity by end_device.
Note that “click” attribute is equal to “action” one but it will be deprecated soon so “action” is the one to use.

Forget about input_boolean, it can be easier with binary_sensor template:

Someting like it:

binary_sensor:
  - platform: template
    sensors:
      switch_1:
        friendly_name: "Switch 1"
        device_class: light
        value_template: >-
           {{ is_state('sensor.0xccccccfffe26a33a','action') and state_attr('sensor.0xccccccfffe26a33a','action_group') | int == 26369 }}

Thanks for the example !

I’m using appdaemon, and I use event callbacks, which operate on entity values. Since the action and action_group are separate entities, and one can fundamentally only subscribe to one entity, I seemingly cannot respond to the action that is connected to the action_group.

I would like to achieve 2 things. The first is to avoid having to write (instantiate) automations in 1, 2 or even 3 places. Appdaemon is good in that respect, using apps.yaml. There is 1 file with the actual automation definition and there is 1 file where the instances are created and the system is defined.

Second, I would like, if possible, to avoid transport specific data in HA. In the appdaemon case, its impact is limited to apps.yaml, but in your binary_sensor example, the hard coding of the Zigbee IeeeAddr and groupID will complicate scaling up. Ideally, HA translates this for me into a meaningful name but it cannot do that based on a value.

I currently created an entity in lib/extension/homeassistant.js based on ‘{{ value_json.action }}/{{ value_json.action_group}}’. Surprisingly, for some reason I get an empty ‘/’ in my callbacks, but that is easy to work around. I still find it a hack. Again, I’d like to keep the groupID out of HA and only use meaningful names.