Skip to content

Commit

Permalink
Remove the distinction between primary and secondary entities.
Browse files Browse the repository at this point in the history
This historical distinction has not mattered for many years now.
It is a source of confusion that primary_entity contained one entity
object and secondary_entities contained a list, making the formats
slightly different, creating a barrier to users making configs.

Combine these into a single `entities` list, and deprecate the old
way.
  • Loading branch information
make-all committed Jan 1, 2025
1 parent 022ea00 commit 3506ae3
Show file tree
Hide file tree
Showing 916 changed files with 36,283 additions and 37,172 deletions.
34 changes: 16 additions & 18 deletions custom_components/tuya_local/devices/9in1_airquality_monitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@ products:
- id: rqhuxgkizawedhxj
name: ZN-2C09
- id: rqhuxgkizawedhxj
primary_entity:
entity: sensor
name: Air Quality
class: enum
icon: "mdi:factory"
dps:
- id: 1
type: string
name: sensor
mapping:
- dps_val: "level_1"
value: "Excellent"
- dps_val: "level_2"
value: "Good"
- dps_val: level_3
value: "Lightly polluted"

secondary_entities:
entities:
- entity: sensor
name: Air Quality
class: enum
icon: "mdi:factory"
dps:
- id: 1
type: string
name: sensor
mapping:
- dps_val: "level_1"
value: "Excellent"
- dps_val: "level_2"
value: "Good"
- dps_val: level_3
value: "Lightly polluted"
- entity: sensor
class: temperature
dps:
Expand Down
27 changes: 13 additions & 14 deletions custom_components/tuya_local/devices/CT20W_pir_motion_detector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@ name: Motion detector
products:
- id: ejptirvg36uwwdwu
name: CT20W PIR Motion Detector
primary_entity:
entity: alarm_control_panel
dps:
- id: 110
type: string
name: alarm_state
mapping:
- dps_val: disarm
value: disarmed
- dps_val: away
value: armed_away
- dps_val: stay
value: armed_home
secondary_entities:
entities:
- entity: alarm_control_panel
dps:
- id: 110
type: string
name: alarm_state
mapping:
- dps_val: disarm
value: disarmed
- dps_val: away
value: armed_away
- dps_val: stay
value: armed_home
- entity: binary_sensor
class: motion
dps:
Expand Down
53 changes: 26 additions & 27 deletions custom_components/tuya_local/devices/DH-CSK03W_dehumidifier.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
name: "DH-CSK03W Dehumidifier"
primary_entity:
entity: humidifier
class: dehumidifier
dps:
- id: 1
name: switch
type: boolean
- id: 2
name: humidity
type: integer
range:
min: 40
max: 70
mapping:
- step: 5
- id: 5
name: mode
type: string
mapping:
- dps_val: "mode_strong"
value: "boost"
- dps_val: "mode_sleep"
value: "sleep"
- id: 6
type: integer
name: current_humidity
secondary_entities:
entities:
- entity: humidifier
class: dehumidifier
dps:
- id: 1
name: switch
type: boolean
- id: 2
name: humidity
type: integer
range:
min: 40
max: 70
mapping:
- step: 5
- id: 5
name: mode
type: string
mapping:
- dps_val: "mode_strong"
value: "boost"
- dps_val: "mode_sleep"
value: "sleep"
- id: 6
type: integer
name: current_humidity
- entity: select
translation_key: timer
category: config
Expand Down
25 changes: 12 additions & 13 deletions custom_components/tuya_local/devices/EM3390TF_weather_station.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@ name: Weather station
products:
- id: cvurn5ynloebrpwy
name: Viflykoo EM3390TF
primary_entity:
entity: sensor
name: Indoor temperature
class: temperature
dps:
- id: 101
type: integer
name: sensor
class: measurement
mapping:
- scale: 10
unit: C
secondary_entities:
entities:
- entity: sensor
name: Indoor temperature
class: temperature
dps:
- id: 101
type: integer
name: sensor
class: measurement
mapping:
- scale: 10
unit: C
- entity: sensor
name: Indoor humidity
class: humidity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ name: Dual water timer
products:
- id: smd9kj1n
name: HCT-626
primary_entity:
entity: valve
name: Valve 1
class: water
dps:
- id: 1
type: boolean
name: valve
secondary_entities:
entities:
- entity: valve
name: Valve 1
class: water
dps:
- id: 1
type: boolean
name: valve
- entity: valve
name: Valve 2
class: water
Expand Down
71 changes: 29 additions & 42 deletions custom_components/tuya_local/devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ This directory contains device configuration files, describing the workings
of supported devices. The files are in YAML format, and describe the mapping
of Tuya DPs (Data Points) to HomeAssistant attributes.

Each Tuya device may correspond to one primary entity and any number of
secondary entities in Home Assistant.
Each Tuya device may correspond to one or more entities in Home Assistant.

## The Top Level

Expand Down Expand Up @@ -34,37 +33,19 @@ when local discovery is implemented to discover products by id, this name will
be displayed on discovery, and be available as manufacturer and model info
in device settings.

### `primary_entity`
### `entities`

This contains the configuration for one Home Assistant entity which is
considered the main entity for the device. For example, if the device is
a heater, this would be a climate entity.
This contains a list of Home Assistant entities providing the functionality
of the device.

The configuration for entities is detailed in its own section below.

### `secondary_entities`

*Optional.*

This contains a list of additional Home Assistant entities
providing additional functionality beyond the capabilities of the primary
entity. Examples include lighting control for display panels as a Home
Assistant light entity, child locks as a Home Assistant lock entity,
or additional toggles as Home Assistant switch entities.

The configuration for secondary entities is the same as primary entities,
and is detailed in the section below.
The configuration for each entity in the list is detailed in the section below.

## Entity configuration

### `entity`

The Home Assistant entity type being configured. Currently supported
types are **climate**, **switch**, **light**, **lock**. Functionality
for these entities is limited to that which has been required for the
devices until now and may need to be extended for new devices. In
particular, the light and lock entities have only been used for simple
secondary entities, so only basic functionality is implemented.
The Home Assistant entity type being configured. See the **Entity types**
section below for details on specific requirements for each entity type.

### `class`

Expand Down Expand Up @@ -114,31 +95,37 @@ This specifies the `entity category` of the entity. Entities can be categorized
as `config` or `diagnostic` to restrict where they appear automatically in
Home Assistant.

### `dps`

This is a list of the definitions for the Tuya DPs associated with
attributes of this entity. There should be one list entry for each
supported DPs reported by the device.

The configuration of DPs entries is detailed in its own section below.

### `name`

*Optional.*

The name associated with this entity can be set here. If no name is set,
it will inherit the name at the top level. This is mostly useful for
overriding the name of secondary entities to give more information
about the purpose of the entity, as the generic type with the top level
name may not be sufficient to describe the function.
The name associated with this entity can be set here. If no name is
set, it will inherit the name at the top level. This is mostly useful
for overriding the name entities to give more information about the
purpose of the entity, or to differentiate multiple entities of the
same type.

Where possible, `translation_key` should be used instead of an explicit name.

### `mode`

*Optional. For number entities, default="auto", for others, None*

For number entities, this can be used to force `slider` or `box` as the
input method. The default `auto` uses a slider if the range is small enough,
or a box otherwise.
or a box otherwise. It is recommended to let HA decide based on its own logic
which mode to use, and override it in the UI settings rather than forcing
your personal preference on others. But if an entity really does only make
sense with one UI mode, then this is provided to handle those cases.

### `dps`

This is a list of the definitions for the Tuya DPs associated with
attributes of this entity. There should be one list entry for each
supported DPs reported by the device.

The configuration of DPs entries is detailed in its own section below.


## DPs configuration

Expand All @@ -165,9 +152,9 @@ The type of data returned by the Tuya API. Can be one of the following:
The name given to the attribute in Home Assistant. Certain names are used
by the Home Assistant entities for specific purposes. If a name is not
recognized as a standard attribute by the entitiy implementation, the
attribute will be returned as a readonly custom attribute on the entity.
attribute will be returned as a readonly extra attribute on the entity.
If you need non-standard attributes to be able to be set, you will need
to use a secondary entity for that.
to use an entity for that (typically switch, number or select).

### `sensitive`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ name: Window opener
products:
- id: ozttm5n6okadq7tq
name: ZC34T-03-3A swing arm opener
primary_entity:
entity: cover
class: window
dps:
- id: 101
type: string
name: control
mapping:
- dps_val: open
value: open
- dps_val: close
value: close
- dps_val: stop
value: stop
secondary_entities:
entities:
- entity: cover
class: window
dps:
- id: 101
type: string
name: control
mapping:
- dps_val: open
value: open
- dps_val: close
value: close
- dps_val: stop
value: stop
- entity: lock
dps:
- id: 102
Expand Down
41 changes: 20 additions & 21 deletions custom_components/tuya_local/devices/abalon_bcm700d_curtain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,26 @@ name: Curtain rail motor
products:
- id: XS76BY5Q1uKO6gjC
name: Abalon BCM700D
primary_entity:
entity: cover
class: curtain
dps:
- id: 101
name: position
type: integer
range:
min: 0
max: 100
- id: 102
name: control
type: string
mapping:
- dps_val: ZZ
value: open
- dps_val: FZ
value: close
- dps_val: STOP
value: stop
secondary_entities:
entities:
- entity: cover
class: curtain
dps:
- id: 101
name: position
type: integer
range:
min: 0
max: 100
- id: 102
name: control
type: string
mapping:
- dps_val: ZZ
value: open
- dps_val: FZ
value: close
- dps_val: STOP
value: stop
- entity: switch
name: Reverse
category: config
Expand Down
Loading

0 comments on commit 3506ae3

Please sign in to comment.