make-all / tuya-local

Local support for Tuya devices in Home Assistant
MIT License
1.41k stars 542 forks source link

Add HLG Infinity Alarm #2521

Closed brunohenriquy closed 3 days ago

brunohenriquy commented 5 days ago

Added support for an unrecognized Alarm Central (HLG Infinity).

brunohenriquy commented 5 days ago

A lot of the sensors here seem to be uninteresting values that would never change. Such values might be better as attributes under another entity to reduce clutter in the UI.

How can I do it? I didn't understand very well!

make-all commented 5 days ago

To add things as extra attributes, you just add them under the dps list with a name that is not handled specially by the entity. For sensors, only "sensor" and "unit" have special handling plus the general things like "name", "device_class" etc, so any other name will be added as an extra attribute.

So instead of:

  - entity: sensor
    name: Sector 1
    icon: "mdi:numeric-1-circle"
    class: enum
    category: diagnostic
    dps:
      - id: 101
        type: string
        name: sensor
        mapping:
          - dps_val: Armado
            value: Armed
          - dps_val: Desarmado
            value: Disarmed
          - dps_val: Memoria
            value: Memory
          - dps_val: Disparado
            value: Triggered
  - entity: sensor
    name: Sector 1 Name
    icon: "mdi:numeric-1-circle-outline"
    category: diagnostic
    dps:
      - id: 120
        type: string
        name: sensor

you could have the name as an attribute of the Sector 1 sensor (since name will not change during operation, so you don't really need to track its state):

  - entity: sensor
    name: Sector 1
    icon: "mdi:numeric-1-circle"
    class: enum
    category: diagnostic
    dps:
      - id: 101
        type: string
        name: sensor
        mapping:
          - dps_val: Armado
            value: Armed
          - dps_val: Desarmado
            value: Disarmed
          - dps_val: Memoria
            value: Memory
          - dps_val: Disparado
            value: Triggered
      - id: 120
        type: string
        name: sensor_name
brunohenriquy commented 5 days ago

To add things as extra attributes, you just add them under the dps list with a name that is not handled specially by the entity. For sensors, only "sensor" and "unit" have special handling plus the general things like "name", "device_class" etc, so any other name will be added as an extra attribute.

Ohhhh Sweet! Thanks!

brunohenriquy commented 3 days ago

@make-all All adjustments have been made, can we proceed to merge it?

brunohenriquy commented 3 days ago

@make-all you've changed the name from "Alarm Central" to "Alam control", shouldn't the file name be renamed to alarm_control.yaml as well?

make-all commented 2 days ago

Thank you for pointing out the file name. It should not be this generic, as this is not a generic device template.

brunohenriquy commented 2 days ago

Thank you for pointing out the file name. It should not be this generic, as this is not a generic device template.

@make-all

But isn't it also wrong having the same name as a product entry? Today it is an specific device template, what if in the future another manufacturer uses the same structure but with a different brand and model name?

make-all commented 2 days ago

The config file name just needs to be unique, so another device matching it does not really matter. But making it too generic when it is not could lead to confusion.

brunohenriquy commented 2 days ago

The config file name just needs to be unique, so another device matching it does not really matter. But making it too generic when it is not could lead to confusion.

Gotcha!! Thanks! xD