Skip to content

Commit

Permalink
Tests: add a check for inconsistent marking as optional.
Browse files Browse the repository at this point in the history
Issues fixed in:
  - beok_tgr81_thermostat.yaml
  - ble_water_valve.yaml
  - ble_ysgbs01_lock.yaml
  - blitzwolf_bw_lt31.yaml
  - comon_lights.yaml
  - eurom_sani_bathroom_towel_radiator.yaml
  - ezaiot_thermostat_smartplug.yaml (renamed lower case, as not yet released)
  - hyd_weair_plus_fan.yaml
  - ironzon_fingerprint_lock.yaml
  - loratap_relay.yaml
  - mellerware_citymove_vacuum.yaml
  - moes_wht009_thermostat.yaml
  - nedis_zbrc10wt_remotecontrol.yaml
  - puppy_kitty_pet_feeder.yaml
  - sensei_airconditioner.yaml
  - wdyk_2p63a_energy_meter.yaml
  - wdyk_4p100a_energymeter.yaml
  - zym100_presence_sensor.yaml
  • Loading branch information
make-all committed Nov 23, 2024
1 parent cca905a commit 71aebc1
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ primary_entity:
max: 90
- id: 19
type: integer
optional: true
name: max_temperature
- id: 24
type: integer
Expand Down Expand Up @@ -110,6 +111,7 @@ secondary_entities:
- value: true
- id: 45
name: fault_code
optional: true
type: bitfield
- entity: number
name: High temperature limit
Expand Down
1 change: 1 addition & 0 deletions custom_components/tuya_local/devices/ble_water_valve.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ secondary_entities:
- value: true
- id: 4
type: bitfield
optional: true
name: fault_code
- entity: sensor
name: Operation
Expand Down
1 change: 1 addition & 0 deletions custom_components/tuya_local/devices/ble_ysgbs01_lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ secondary_entities:
dps:
- id: 21
type: string
optional: true
name: sensor
mapping:
- dps_val: low_battery
Expand Down
3 changes: 0 additions & 3 deletions custom_components/tuya_local/devices/blitzwolf_bw_lt31.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ primary_entity:
- id: 103
name: line_sequence_adjustment
type: integer
- id: 104
name: strip_points
type: integer
secondary_entities:
- entity: select
name: Music
Expand Down
1 change: 1 addition & 0 deletions custom_components/tuya_local/devices/comon_lights.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ secondary_entities:
- id: 102
type: string
name: option
optional: true
mapping:
- dps_val: "1e03e801f40000000"
value: Combination - All
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ secondary_entities:
dps:
- id: 105
type: integer
optional: true
name: sensor
unit: C
- entity: sensor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ primary_entity:
- scale: 10
- id: 9
type: integer
name: max_temperature
optional: true
name: max_temperature
mapping:
- scale: 10
- id: 12
Expand All @@ -41,6 +41,9 @@ primary_entity:
unit: C
mapping:
- scale: 10
range:
min: -30
max: 110
- id: 114
type: integer
name: hvac_action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ secondary_entities:
- value: true
- id: 13
type: bitfield
optional: true
name: fault_code
- entity: switch
name: Beep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ secondary_entities:
- value: true
- id: 21
type: string
optional: true
name: details
- entity: binary_sensor
class: lock
Expand Down
6 changes: 0 additions & 6 deletions custom_components/tuya_local/devices/loratap_relay.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ secondary_entities:
value: "on"
- dps_val: 2
value: memory
- id: 42
type: string
name: cycle_time
- id: 43
type: string
name: random_time
- entity: select
name: Light Mode
category: config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ primary_entity:
name: power
- id: 17
type: bitfield
optional: true
name: error
hidden: true
- id: 101
Expand Down Expand Up @@ -127,13 +128,17 @@ secondary_entities:
dps:
- id: 17
type: bitfield
optional: true
name: sensor
mapping:
- dps_val: 0
value: false
- dps_val: null
value: false
- value: true
- id: 17
type: bitfield
optional: true
name: fault_code
- id: 17
type: bitfield
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@ primary_entity:
step: 5
- id: 19
type: integer
optional: true
name: max_temperature
mapping:
- scale: 10
- id: 26
type: integer
optional: true
name: min_temperature
mapping:
- scale: 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ primary_entity:
- value: pressed
- id: 29
type: string
optional: true
name: code
secondary_entities:
- entity: event
Expand All @@ -33,6 +34,7 @@ secondary_entities:
- value: pressed
- id: 27
type: string
optional: true
name: code
- entity: event
name: Button A
Expand All @@ -48,6 +50,7 @@ secondary_entities:
- value: pressed
- id: 28
type: string
optional: true
name: code
- entity: event
name: Button B
Expand All @@ -63,6 +66,7 @@ secondary_entities:
- value: pressed
- id: 26
type: string
optional: true
name: code
- entity: sensor
class: battery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ secondary_entities:
- value: false
- id: 4
type: string
optional: true
name: raw
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ secondary_entities:
dps:
- id: 105
type: string
optional: true
name: option
mapping:
- dps_val: c
Expand Down
12 changes: 2 additions & 10 deletions custom_components/tuya_local/devices/wdyk_2p63a_energy_meter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,13 @@ secondary_entities:
type: boolean
name: switch
- entity: button
name: Reset energy
name: Reset balance energy
category: config
class: restart
dps:
- id: 12
type: boolean
optional: true
name: button
- entity: sensor
name: Energy balance
Expand Down Expand Up @@ -336,12 +337,3 @@ secondary_entities:
type: boolean
name: button
optional: true
- entity: button
name: Reset balance energy
class: restart
category: config
dps:
- id: 12
type: boolean
name: button
optional: true
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,6 @@ secondary_entities:
- id: 11
type: boolean
name: switch
- entity: button
name: Reset energy
category: config
class: restart
dps:
- id: 12
type: boolean
name: button
- entity: sensor
name: Energy balance
class: energy_storage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ secondary_entities:
- value: true
- id: 6
type: string
optional: true
name: description
- entity: sensor
name: Target distance
Expand Down
19 changes: 15 additions & 4 deletions tests/test_device_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,18 +531,29 @@ def test_config_files_parse(self):
def test_configs_can_be_matched(self):
"""Test that the config files can be matched to a device."""
for cfg in available_configs():
required_dps = 0
optional = set()
required = set()
parsed = TuyaDeviceConfig(cfg)
for entity in parsed.all_entities():
for dp in entity.dps():
if not dp.optional:
required_dps += 1
if dp.optional:
optional.add(dp.id)
else:
required.add(dp.id)

self.assertGreater(
required_dps,
len(required),
0,
msg=f"No required dps found in {cfg}",
)

for dp in required:
self.assertNotIn(
dp,
optional,
msg=f"Optional dp {dp} is required in {cfg}",
)

# Most of the device_config functionality is exercised during testing of
# the various supported devices. These tests concentrate only on the gaps.

Expand Down

0 comments on commit 71aebc1

Please sign in to comment.