Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
make-all authored Feb 29, 2024
2 parents a056d85 + b763456 commit ae02068
Show file tree
Hide file tree
Showing 375 changed files with 966 additions and 1,349 deletions.
7 changes: 6 additions & 1 deletion custom_components/tuya_local/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_HOST
from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import ConfigEntryNotReady
from homeassistant.helpers.entity_registry import async_migrate_entries
from homeassistant.util import slugify

Expand Down Expand Up @@ -311,7 +312,11 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
get_device_id(entry.data),
)
config = {**entry.data, **entry.options, "name": entry.title}
setup_device(hass, config)
try:
setup_device(hass, config)
except Exception as e:
raise ConfigEntryNotReady("tuya-local device not ready") from e

device_conf = get_config(entry.data[CONF_TYPE])
if device_conf is None:
_LOGGER.error(NOT_FOUND, config[CONF_TYPE])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,16 +92,14 @@ secondary_entities:
value: false
- value: true
- entity: lock
name: Child lock
translation_key: child_lock
category: config
icon: "mdi:hand-back-right-off"
dps:
- id: 16
type: boolean
name: lock
- entity: select
name: Timer
icon: "mdi:timer"
translation_key: timer
category: config
dps:
- id: 17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ secondary_entities:
value: true
- entity: sensor
class: battery
unit: "%"
dps:
- id: 2
type: integer
name: sensor
unit: "%"
- entity: binary_sensor
class: plug
dps:
Expand Down
16 changes: 14 additions & 2 deletions custom_components/tuya_local/devices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ listing can also have an optional `name`, which is intended to specify the
specific brand and model name or number of the matching device. In future
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 (so probably in future name will be split into manufacturer
and model, but for now, putting them together as name is OK).
in device settings.

### `primary_entity`

Expand Down Expand Up @@ -77,6 +76,19 @@ behaviour.
For most entities, it will alter the default icon, and for binary sensors
also the state that off and on values translate to in the UI.

### `translation_key` / `translation_only_key`

*Optional*

A key used to define strings and icons for this entity. If this is used,
the name can be omited and instead defined in the translations files.

`translation_key` will be used to generate IDs when there is no name defined.
If the intention is to have an unnamed entity, or to inherit from class, then
use `translation_only_key` instead (this is mostly useful to retain
backward compatibility where `translation_key` is used to define icons and
attribute strings but not the entity name.

### `category`

*Optional.*
Expand Down
4 changes: 2 additions & 2 deletions custom_components/tuya_local/devices/agl_ultramagic_lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ secondary_entities:
range:
min: 1
max: 1200
unit: s
unit: s
- entity: number
category: config
icon: "mdi:alarm"
Expand All @@ -117,4 +117,4 @@ secondary_entities:
range:
min: 0
max: 100
unit: s
unit: s
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,12 @@ secondary_entities:
- dps_val: true
icon: "mdi:sleep"
- entity: lock
name: Child lock
translation_key: child_lock
category: config
dps:
- id: 16
type: boolean
name: lock
mapping:
- dps_val: false
icon: "mdi:hand-back-right"
- dps_val: true
icon: "mdi:hand-back-right-off"
- entity: binary_sensor
class: problem
name: Tank full
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,12 @@ secondary_entities:
- dps_val: null
invalid: true
- entity: lock
name: Child lock
translation_key: child_lock
category: config
dps:
- id: 7
type: boolean
name: lock
mapping:
- dps_val: false
icon: "mdi:hand-back-right"
- dps_val: true
icon: "mdi:hand-back-right-off"
- entity: select
name: Countdown
icon: "mdi:timer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,14 @@ secondary_entities:
value: false
- value: true
- entity: lock
name: Child lock
translation_key: child_lock
category: config
dps:
- id: 14
type: boolean
name: lock
mapping:
- dps_val: true
icon: "mdi:hand-back-right-off"
- dps_val: false
icon: "mdi:hand-back-right"
- entity: select
name: Timer
icon: "mdi:timer"
translation_key: timer
category: config
dps:
- id: 17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,20 +134,14 @@ secondary_entities:
value: false
- value: true
- entity: lock
name: Child lock
translation_key: child_lock
category: config
dps:
- id: 14
type: boolean
name: lock
mapping:
- dps_val: true
icon: "mdi:hand-back-right-off"
- dps_val: false
icon: "mdi:hand-back-right"
- entity: select
name: Timer
icon: "mdi:timer"
translation_key: timer
category: config
dps:
- id: 17
Expand Down
5 changes: 2 additions & 3 deletions custom_components/tuya_local/devices/anko_fan.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Anko fan
primary_entity:
entity: fan
translation_key: fan_with_presets
translation_only_key: fan_with_presets
dps:
- id: 1
type: boolean
Expand Down Expand Up @@ -49,8 +49,7 @@ primary_entity:
name: timer
secondary_entities:
- entity: number
name: Timer
icon: "mdi:timer"
translation_key: timer
category: config
dps:
- id: 6
Expand Down
3 changes: 1 addition & 2 deletions custom_components/tuya_local/devices/ard100_valve.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ primary_entity:
name: switch
secondary_entities:
- entity: number
name: Timer
icon: "mdi:timer"
translation_key: timer
category: config
dps:
- id: 7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ products:
- id: rklgm99ldz4unh5s
primary_entity:
entity: fan
translation_key: fan_with_presets
translation_only_key: fan_with_presets
dps:
- id: 1
name: switch
Expand Down Expand Up @@ -54,8 +54,7 @@ primary_entity:
name: fault_code
secondary_entities:
- entity: select
name: Timer
icon: "mdi:timer"
translation_key: timer
category: config
dps:
- id: 6
Expand Down
5 changes: 2 additions & 3 deletions custom_components/tuya_local/devices/arlec_19speed_fan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ products:
name: Arlec 19-speed industrial wall fan
primary_entity:
entity: fan
translation_key: fan_with_presets
translation_only_key: fan_with_presets
dps:
- id: 1
name: switch
Expand Down Expand Up @@ -33,9 +33,8 @@ primary_entity:
type: bitfield
secondary_entities:
- entity: number
name: Timer
translation_key: timer
category: config
icon: "mdi:timer"
dps:
- id: 22
type: integer
Expand Down
5 changes: 2 additions & 3 deletions custom_components/tuya_local/devices/arlec_6speed_fan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ products:
name: Arlec 45cm black floor fan
primary_entity:
entity: fan
translation_key: fan_with_presets
translation_only_key: fan_with_presets
dps:
- id: 1
name: switch
Expand Down Expand Up @@ -66,8 +66,7 @@ secondary_entities:
value: false
- value: true
- entity: select
name: Timer
icon: "mdi:timer"
translation_key: timer
category: config
dps:
- id: 6
Expand Down
5 changes: 2 additions & 3 deletions custom_components/tuya_local/devices/arlec_fan.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ARLEC Grid Connect Fan
primary_entity:
entity: fan
translation_key: fan_with_presets
translation_only_key: fan_with_presets
dps:
- id: 1
name: switch
Expand Down Expand Up @@ -30,8 +30,7 @@ primary_entity:
type: string
secondary_entities:
- entity: select
name: Timer
icon: "mdi:timer"
translation_key: timer
category: config
dps:
- id: 103
Expand Down
5 changes: 2 additions & 3 deletions custom_components/tuya_local/devices/arlec_fan_light.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: ARLEC fan with light
primary_entity:
entity: fan
translation_key: fan_with_presets
translation_only_key: fan_with_presets
dps:
- id: 1
name: switch
Expand Down Expand Up @@ -50,8 +50,7 @@ secondary_entities:
min: 2700
max: 6500
- entity: select
name: Timer
icon: "mdi:timer"
translation_key: timer
category: config
dps:
- id: 103
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ primary_entity:
optional: true
secondary_entities:
- entity: number
name: Timer
translation_key: timer
category: config
icon: "mdi:timer"
dps:
- id: 105
type: integer
Expand Down
6 changes: 2 additions & 4 deletions custom_components/tuya_local/devices/arlec_panel_heater.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ primary_entity:

secondary_entities:
- entity: lock
name: Child lock
icon: "mdi:hand-back-right-off"
translation_key: child_lock
category: config
dps:
- id: 6
Expand All @@ -61,9 +60,8 @@ secondary_entities:
optional: true
name: alternate
- entity: number
name: Timer
translation_key: timer
category: config
icon: "mdi:timer"
dps:
- id: 10
type: integer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,15 @@ primary_entity:
value: unknown
secondary_entities:
- entity: lock
name: Child lock
icon: "mdi:hand-back-right-off"
translation_key: child_lock
category: config
dps:
- id: 7
type: boolean
name: lock
- entity: number
name: Timer
translation_key: timer
category: config
icon: "mdi:timer"
dps:
- id: 19
type: string
Expand Down
Loading

0 comments on commit ae02068

Please sign in to comment.