Sensor with multiple binary state?

Hello,

I’m trying to develop my custom component, and facing some issue on the way I should implement some sensor.

I have multiple devices with each one of them providing multiple state for different class.
For exemple :
device 1, I can get : battery status, communication status, lock status, etc. (many binary state in fact).
device 2 : the same
etc.

What kind of sensor should I do ? Can I get a sensor for each device, so N sensors ? Or should i have a binary sensor for all differents states for all devices ? (N devices * X binary states).

Thanks.

I believe many entities provide a state, and other details like those appear as attributes of the state object. But I’m not a component developer and may be misunderstanding your intent.

I think you should do whatever kind of sensors suits your application. If you only need one sensor per device, then yeah N sensors (for N devices). OTOH, if you need battery, comms, lock, etc status for each device, that will need more than one sensor obviously (so N*x, where x = sensors per device). Binary states?.. you know the difference between a binary and non-binary sensor right? Use whichever suits the application… ie lock status is probably binary, battery could be binary (dead/alive) or non-binary (voltage reading).

Without more detailed info on the specific application, we can’t give specific advice.

I know the dffierences.

Can I do one sensor and use attributes ? If yes how I can retrieve attributes then in Lovelace ?

if you have something like device_class_sttributes in your component, you’ll see all of them on the component’s state card - check out this source as an example.

Thanks.

So I need some advices.

When I request my API, I get this result :

  {
    'elt_onde': [u'itemcomok', u'itemhidden', u'itemhidden', u'itemcomok', u'itemcomok', u'itemcomok', u'itemcomok', u'itemcomok', u'itemcomok', u'itemcomok'], 
    'elt_bat': [u'itembattok', u'itemhidden', u'itemhidden', u'itembattnok', u'itembattok', u'itembattok', u'itembattnok', u'itembattok', u'itembattok', u'itembattok'], 
    'item_label': [u'Trans', u'Badge', u'Teleco', u'Clavier', u'DO', u'DO', u'Sirene', u'DM', u'DM', u'DM'], 
    'item_pause': [u'running', u'running', u'running', u'running', u'running', u'running', u'running', u'running', u'running', u'running'], 
    'item_type': [u'typetrans', u'typebadgerfid', u'typeremote4', u'typekeyb', u'typedo', u'typedo', u'typesirenint', u'typedm', u'typedm', u'typedm'], 
    'elt_code': [u'0000', u'1111', u'2222', u'3333', u'4444', u'5555', u'6666', u'7777', u'8888', u'9999'], 
    'elt_as': [u'itemboxok', u'itemhidden', u'itemhidden', u'itemboxok', u'itemboxok', u'itemboxok', u'itemboxok', u'itemboxok', u'itemboxok', u'itemboxok'], 
    'elt_porte': [u'itemhidden', u'itemhidden', u'itemhidden', u'itemhidden', u'itemdoorok', u'itemdoorok', u'itemhidden', u'itemhidden', u'itemhidden', u'itemhidden']
 }

It is all the state of all the devices. The particularity is that the key of this dict, is a binary state, and the element position on the list is the device.

The first column of each list is the same device, the 2nd one is another device.
So, for example, the device on the first column will get theses states :

  • elt_onde : itemcomok
  • elt_bat : itembatok
  • item_label : Trans

etc. etc.

Based on that, what should I do ? Create a binary sensor for each item ? Create only one and works with attributes ?

I don’t really know from what perspective take this problem.

Hi @pschittt ,

Look like you’re using a Somfy Protexial IO alarm ?

If yes, you can try my add-on => Somfy Protexial Alarm.

Regards,

Florian

Hello,

In fact I’ve developed my own custom component : https://github.com/Pschittt/HASS-Somfy-Protexiom

It’s not for protexial IO but for the older one protexiom.

Maybe there is a way to merge our 2 projects to have only one custom component :wink: