Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor lightToMap() and sensorToMap() #7979

Open
wants to merge 59 commits into
base: master
Choose a base branch
from

Conversation

ebaauw
Copy link
Collaborator

@ebaauw ebaauw commented Oct 18, 2024

This PR refactors the construction of the API responses to GET /lights and GET /sensorsand of web socket notifications for/lightsand/sensors`. It builds on #7961, which should be merged first.

Changes

This PR makes the following changes:

  • Set the following items as non-public, since they shouldn't be shown in the API:
    • attr/id;
    • attr/otaversion;
    • cap/bri/move_with_onoff;
    • cap/on/off_with_effect;
    • config/bri/options.
  • Change the data type to Double for the following items:
    • state/current and variants;
    • state/power;
    • state/pressure and bis;
    • state/voltage.
  • Add non-public item state/power_divisor for the IKEA INSPELNING (see IKEA INSPELNING Smart Plug with kWh meter #7948). Note that this needs to be defined in C++ for it to be used in expressions in the DDF.
  • Add ResourceItemDescriptor::toApi(), which returns a pointer to the (sub-)map and the key where the value of the corresponding item should be inserted in the API response map. Any intermediate sub-maps are created where needed. It returns a small helper class ApiAttribute containing a QVariantMap pointer (to the sub-map) and two QString (for the key and top-level key).
  • Refactor lightsToMap() and sensorsToMap():
    • Remove the need to whitelist resource items with a value that can be obtained by toVariant(). The entire multi-level map structure is now built dynamically. This leaves only two types of whitelisted resource items:
      • Those with a complex value (like config/on/startup, that's either a boolean or "default");
      • Those that are reported in a combined value (like state/xy, built from state/x and state/y).
    • Insert the public resource items from the parent device into the response. This is done before the lights or sensors resource items are processed, so these might override the parent values. In practice, this causes the following additional keys in the API response: attr/ddf_hash, attr/ddf_policy, attr/extaddress, attr/nwkaddress, cap/sleeper, and (for /sensors) state/reachable. Note that non-Zigbee sensors don't have a parent device.
    • Remove (what I believe to be) dead code:
      • Special exception for Hue App (ApiModeHue). Afaik the Hue app hasn't been working with deCONZ for a long time anyway, and there are alternatives, like Hue Essentials.
      • A hook to exclude certain items when the functions are invoked for GET /devices. Currently they aren't, and the hook would be obsolete once we move those items from the sub-devices to the device.
    • Handle needPushChange logic to support web socket notifications.
  • Refactor handleLightEvent() to leverage lightToMap().
  • Refactor handleSensorEvent() to leverage sensorToMap().
  • Change all string constants in the refactored functions to QLatin1String instances.

Discussion

  • While removing the device items from the sub devices will work brilliantly for GET, I'm not sure what the logic for the web socket notifications on those items should be. I don't think we currently do notifications on /devices? Would we want a single notification on the device level, or a separate notifications on each sub device? In the latter case, I think we would need "slave" resource items on the sub-devices to keep track of what's already been notified.
  • We might want to mark some of the device resource items as non-public?
  • Do we want to deprecate config/reachable (for /sensors) in favour of state/reachable? Same for config/alert?

Next Steps

  • Figure out how to deal with web socket notifications for device-level attributes.
  • Move following items to the device:
    • attr/lastannouced, attr/lastseen;
    • cap/otau/...;
    • cap/alerts, state/alert, config/alert: in theory these could be per endpoint (with Identify cluster)

Copy link
Contributor

github-actions bot commented Oct 18, 2024

Hey @ebaauw, thanks for your pull request!

Tip

Modified bundles can be downloaded here.
Relative expire date

DDB changes

Modified

  • aeotec/WG001-Z01_range_extender.json : Range extender zi (ZAG001-C15) ✔️

  • 3A-Nue/lxn59-1s7lx1.0.json : 1 gang inline switch (ZW-EU-01) ✔️

  • gledopto/gl-sd-002_switch.json : Switch module (GL-SD-002) ✔️

  • lidl/hg06338.json : SilverCrest power strip 3 AC (16A) with 4 USB (HG06338) ✔️

  • philips/bridge.json : Hue bridge ✔️

  • sonoff/zbmini-l_relay.json : Mini Relay No Neutral (ZBMINI-L/ZBMINIL2) ✔️

  • tuya/_TYZB01_TS0011_1gang_wired_no_neutral.json : Light switch (TS0011) ✔️

  • tuya/_TZE200_amp6tsvy_wired_switch_1gang.json : Tuya 1 gang wired switch (TS0601) ✔️

  • tuya/_TZ3000__TS0207_range_extender.json : Range Extender (TS0207) ✔️

  • 3A-Nue/Lxn59-2s7lX1.0.json : 2 gang inline switch (ZW-EU-02) ✔️

  • home2link/H2L-ZBPH-RS.json : Hue Curtain Motor controller (H2L-ZBPH-RS) ✔️

  • ledvance/ledvance_plug_compact_eu_t.json : PLUG COMPACT EU T ✔️

  • orvibo/CM10ZW.json : Dry contact (CM10ZW) ✔️

  • neo/TS0012_Immax_smart_controller.json : Immax Smart controller (TS0012) ✔️

  • osram/plug_01.json : Smart+ Plug (AB3257001NJ) ✔️

  • robb_smarrt/rob_200-029-0_covering.json : Roller Shutter Switch (ROB_200-029-0) ✔️

  • tuya/_TS0012_2gangs_wired_no_neutral_not_locked.json : Tuya 2 gangs wired without neutral (TS0012) ✔️

  • sunricher/SR-ZG9080A.json : Curtain motor controller (SR-ZG9080A) ✔️

  • tuya/_TZ3000_TS0011_1gang_switch_module.json : 1 gang switch module (TS0011) ✔️

  • tuya/_TZ3000_qewo8dlz_wired_switch_3gangs.json : Wired Switch 3 gangs (TS0013) ✔️

  • tuya/_TZ3000_gzvniqjb_din_rail_switch.json : DIN rail circuit breaker 63A (TO-Q-SY1-ZT) ✔️

  • tuya/_TZ3000_jl7qyupf_2gangs_switch_locked.json : Wired switch 2 gangs (TS0012) ✔️

  • xiaomi/lumi_curtain.json : Smart Curtain Controller (ZNCLDJ11LM) ✔️

  • ikea/tradfri_bulb_e14_ww_clear_250lm.json : Tradfri LED bulb E14 250 lumen WW clear, dimmable (LED1935C3) ✔️

  • ikea/askvader_on_off_switch.json : Askvader On/off switch (E1836) ✔️

  • ikea/tradfri_bulb_gu10_ww_400lm.json : Tradfri LED bulb GU10 400 lumen, dimmable/warm white (LED1837R5) ✔️

  • ikea/tretakt_smart_plug.json : TRETAKT Smart plug (E2204) ✔️

  • ikea/tradfri_signal_repeater.json : Tradfri signal repeater (E1746) ✔️

  • ikea/tradfri_control_outlet.json : Tradfri Control Outlet (E1603) ✔️

  • moes/Moes_MS-104BZ_wired_switch_2_gangs.json : Wired Switch 2 gangs (MS-104BZ) ✔️

  • moes/Moes_ZM-105-M_1_gang_dimmer.json : Switch (TS0601) ✔️

  • tuya/_TZ3000_2channel_module.json : 2 output module (TS0002) ✔️

  • tuya/_TS130F_standard_covering_reversed.json : Standard covering (TS130F) ✔️

  • tuya/_TZ3000_hkkkuk7k_mini_switch.json : 2 output module (TS0012) ✔️

  • tuya/_TZ3000_pfc7i3kt_smart_switch_3gangs_locked.json : Switch module 3 channel (TS0003) ✔️

  • tuya/_TZ3000_wkr3jqmr_4channel_module.json : 4 output module (TS0004) ✔️

  • tuya/_TZE200_2wg5qrjy_valve.json : Water valve (ZX-7155-675) ✔️

  • wiser/dimmer_module.json : Wiser 40/300-series module dimmer (41EPBDWCLMZ/354PBDMBTZ) ✔️

  • easyaccess/easyfingertouch_doorlock.json : Keypad doorlock (Various models) ✔️

  • ikea/somrig_shortcut_button.json : Somrig shortcut button (E2213) ✔️

  • lds/ZBT-DIMSwitch-D0000_remote.json : Wireless dimmer knob (LA-AAN-UIT-7A) ✔️

  • konke/3AFE280100510001_battery_switch.json : Kit pro multi function button (KPKEY) ✔️

  • innr/rc_250.json : 5-key wireless remote control (RC 250) ✔️

  • legrand/Remote_switch_Wakeup_sleep.json : Valena life scene switch wakeup and sleep (752x89/064884) ✔️

  • legrand/wireless_scenes_command.json : Wireless 4 scenes control switch celiane (0 677 55/56/57) ✔️

  • legrand/Remote_switch_home_away.json : Home and Away wireless master switch celiane (064873) ✔️

  • mhcozy/ts0004.json : 4-channel dry contact smart wireless zigbee switch relay module (TS0004) ✔️

  • moes/Moes_MS-105-M_1_gang_dimmer_module.json : 1-gang dimmer module (ZM-105-M) ✔️

  • paulmann/501_34_battery_switch.json : Wall switch on/off/dimm (501.34) ✔️

  • sonoff/snzb-01p_switch_wireless.json : Wireless Switch (SNZB-01P) ✔️

  • moes/Moes_TZ3000_TS0012_2_gang_switches.json : 2 gang switches (TS0012) ✔️

  • sonoff/snzb-05p.json : SNZB-05P ✔️

  • sunricher/zg2855-rgb_button.json : 3 in 1 zigbee push button remote (ZG2855-RGB) ✔️

  • third_reality/3RSB22BZ_smart_button.json : Smart Button 3RSB22BZ ✔️

  • tuya/_TZ3000_TS011F_PowerStrip.json : Powerstrip with USB (TS011F) ✔️

  • tuya/_TZE200_9cxuhakf_wired_dimmer.json : Switch Mechanism (SSWM-DIMZ) ✔️

  • wattle/hc-slm-1_doorlock.json : Door lock SPL smart (HC-SLM-1) ✔️

  • tuya/_TZE200_e3oitdyu_smart_dimmer_module.json : Smart Dimmer Module (TS0601) ✔️

  • wiser/fuga_4button_battery_switch.json : LK Fuga Wiser wireless battery 2 or 4 button switch (550D6001/WDE002906) ✔️

  • wiser/meg5113-0300_cover_controller.json : Merten Wiser cover controller (MEG5113-0300) ✔️

  • xiaomi/xiaomi_wxkg01lm_mini_switch.json : Wireless mini switch (WXKG01LM) ✔️

  • eva/powermeter.json : Meter Reader ✔️

  • ikea/tradfri_bulb_gu10_w_400lm.json : Tradfri LED bulb GU10 400 lumen, dimmable white (LED1650R5) ✔️

  • ledvance/b40_dim_z3.json : B40 DIM Z3 ✔️

  • innr/xx_110.json : Puck Light White Extension Pack and Under Cabinet Light (PL 110/UC 110) ✔️

  • ikea/tradfri_bulb_e27_ww_806lm.json : Tradfri LED bulb E27 806 lumen, smart wireless dimmable/white spectrum globe (LED1836G9) ✔️

  • osram/classic_a60_fil_dim_t.json : Smart+ filament classic dimmable A52D 6W E27 (4058075729209) ✔️

  • osram/classic_a60_w_clear.json : Lightify LED classic A60 clear ✔️

  • owon/THS317-ET_temperature_sensor.json : Temperature sensor with probe (THS317-ET) ✔️

  • sonoff/snzb-06p.json : Human presence sensor (SNZB-06P) ✔️

  • sunricher/2button_switch.json : 2 button wall switch ✔️

  • sunricher/4button_switch.json : 4 button wall switch ✔️

  • sunricher/vivares_pbc4_01.json : Push button coupler C4 (SR-ZG2833PAC-C4) ✔️

  • sunricher/8button_switch.json : 8 button wall switch ✔️

  • terncy/terncy_dc01_contact_sensor.json : Door sensor (TERNCY-DC01) ✔️

  • tuya/_TZ3000_TS0042_2gang_remote.json : 2-gang remote (TS0042) ✔️

  • tuya/_TZ3000_TS0041_1gang_remote.json : 1-gang remote (TS0041) ✔️

  • tuya/_TZ3000_TS0044_4gang_remote.json : Tuya 4-gang remote (TS0044) ✔️

  • tuya/_TZ3000_TS0043_3gang_remote.json : 3-gang remote (TS0043) ✔️

  • tuya/_TZ3000_TS004F_switch.json : Scene switch (TS004F) ✔️

  • tuya/_TZE200_pay2byax_openclose_sensor.json : Open/close sensor (ZG-102Z/TM001-ZA/TM081) ✔️

  • ubisys/c4_5504.json : Control unit (C4 (5504)) ✔️

  • xiaomi/xiaomi_dw-s03d_t1_openclose_sensor.json : T1 open/close sensor (DW-S03D) ✔️

  • xiaomi/xiaomi_wb-r02d_t1_wireless_mini_switch.json : T1 wireless mini switch (WB-R02D) ✔️

  • xiaomi/xiaomi_sjcgq13lm_e1_wleak_sensor.json : E1 water leak sensor (SJCGQ13LM) ✔️

  • xiaomi/xiaomi_wxkg11lm_mini_switch.json : Wireless mini switch (WXKG11LM) ✔️

  • adeo/ldsenk09_keyfob.json : Lexman smart compact keyfob (LDSENK09) ✔️

  • develco/iomzb-110_switch_module.json : Dry contact IO-module (IOMZB-110) ✔️

  • computime-salus/ss909zb_temp_sensor.json : Pipe temperature sensor (PS600) ✔️

  • ikea/styrbar_remote_control.json : Styrbar remote control (E2002) ✔️

  • ikea/symfonisk_sound_remote_gen2.json : Symfonisk sound remote gen2 (E2123) ✔️

  • ikea/tradfri_open_close_remote.json : Tradfri open/close remote (E1766) ✔️

  • ikea/tradfri_shortcut_button.json : Tradfri shortcut button (E1812) ✔️

  • lidl/hg06668.json : Silvercrest doorbell (HG06668) ✔️

  • sonoff/snzb-03p_motion_sensor.json : Motion sensor ✔️

  • tuya/_TZE200_dq1mfjug_smoke_sensor.json : Smoke sensor (TS0601) ✔️

  • tuya/_TZ3000_TS0044_4gang_remote_locked.json : 4-gang remote (TS0044) ✔️

  • tuya/_TZ3000_ja5osu5g_smart_button.json : Wireless smart button (TS004) ✔️

  • immax/07046L_keyfob.json : Neo smart keyfob (07046L) ✔️

  • woox/woox_r7054_remote.json : 4 gang switch (R7054) ✔️

  • xiaomi/lumi_sensor_wleak_aq1.json : Water leak sensor (SJCGQ11LM) ✔️

  • xiaomi/xiaomi_lumi.curtain.agl001.json : Curtain Driver E1 (ZNCLBL01LM) ✔️

  • danfoss/ally_temp_hum_sensor.json : Ally temperature and humidity sensor (014G2480) ✔️

  • heiman/hs1rc_keyfob.json : Remote controller (HS1RC) ✔️

  • hzc_electric/s900w-zg_water_leak_sensor.json : Water leak sensor (S900W-ZG) ✔️

  • heiman/hs1sa_smoke_sensor.json : Smoke sensor (HS1SA) ✔️

  • ikea/tradfri_on_off_switch.json : Tradfri on/off switch (E1743) ✔️

  • ikea/tradfri_remote_control.json : Tradfri remote control (E1810) ✔️

  • ikea/badring_water_leak_sensor.json : Badring Water leakage sensor (E2202) ✔️

  • ikea/tradfri_wireless_dimmer.json : Tradfri wireless dimmer (E1724) ✔️

  • iluminize/led_controller_multi_5.dim.json : LED Controller Multi 5 (DIM mode) ✔️

  • iluminize/roller_shutter_actuator_mini.json : Curtain controller (5128.10) ✔️

  • moes/Moes_TZ3000_TS0201_temp_hum_with_LCD.json : Temperature and humidity sensor (TS0201) ✔️

  • linkind/001082_water_leak_sensor.json : Water leak sensor (LS21001) ✔️

  • legrand/Contactor.json : Contactor ✔️

  • namron/4512762_open_close_sensor.json : Open/close sensor (4512762) ✔️

  • nedis/nedis_zbrc10wt.json : 4 button remote (ZBRC10WT) ✔️

  • namron/4512765_hum_temp.json : Temperature and humidity sensor (4512765/S903TH-ZG) ✔️

  • nexentro/nexentro_blinds_actuator_mini.json : Blinds Actuator ✔️

  • orvibo/sf21_smoke_sensor.json : Smoke detector (SF21) ✔️

  • plaid_systems/ps-sprzms-slp3_soil_sensor.json : Spruce Soil sensor (PS-SPRZMS-SLP3) ✔️

  • smabit/AV201021C_door_sensor.json : Flat magnetic contact sensor (AV2010/21C) ✔️

  • sonoff/snzb-02-multisensor.json : Temperature And Humidity Sensor (SNZB-02) ✔️

  • schwaiger/zhs20_smoke_detector.json : Smoke detector (ZHS20) ✔️

  • tesla/TSL-SEN-TAH_multi_sensor.json : Temperature and humidity sensor (TSL-SEN-TAH) ✔️

  • third_reality/3RTHS24BZ_multi_sensor.json : Temperature and humidity sensor with digital LCD display (3RTHS24BZ) ✔️

  • tuya/_TYZB01_SM0201_temp_hum_sensor.json : Temperature and humidity sensor with LCD display (SM0201) ✔️

  • tuya/_TZE200_2ekuz3dz_trv.json : Under floor heating thermostat (TS0601) ✔️

  • wiser/fuga_double_relay_switch.json : LK Fuga Wiser wireless double relay (545D6514) ✔️

  • woox/woox_r7048_hum_temp_sensor.json : Temperature and Humidity Sensor (R7048) ✔️

  • wiser/switch_1Gang.json : Merten PlusLink relay insert (MEG5161-0000) ✔️

  • woox/Woox_R7049_Smart_Smoke_Alarm.json : Smart smoke alarm (R7049) ✔️

  • woox/woox_r7052_ts0215a.json : Smart SOS button (R7052) ✔️

  • woox/woox_r7060_ts0101.json : Smart garden irrigation control (R7060) ✔️

  • xiaomi/lumi_sensor_occupy.agl1.json : Presence Sensor FP1E (PS-SE03) ✔️

  • xiaomi/xiaomi_lywsd03mmc.json : Temperature and humidity sensor with LCD (LYWSD03MMC) ✔️

  • xiaomi/xiaomi_mccgq01lm_openclose_sensor.json : Open/close sensor (MCCGQ01LM) ✔️

  • xiaomi/xiaomi_mccgq14lm_e1_openclose_sensor.json : E1 open/close sensor (MCCGQ14LM) ✔️

  • xiaomi/xiaomi_mho-c401n_temp_hum_sensor.json : Temperature and humidity sensor with display (MHO-C401N) ✔️

  • Jasco-GE/GE45856_wall_switch.json : GE ZigBee in-wall smart switch (45856GE) ✔️

  • blitzwolf/bw_is4_multisensor.json : Temperature and humidity sensor with display (BW-IS4) ✔️

  • bosch/plug_compact.json : Plug compact EU (BSP-FZ2) ✔️

  • aubess/aubess_multi_sensor_TZ3000_bguser20.json : Temperature and humidity sensor (WSD500A) ✔️

  • bosch/bsd-2-smoke-alarm.json : Smoke alarm II (BSD-2) ✔️

  • bosch/bwa-1_water_sensor.json : Water alarm (BWA-1) ✔️

  • heiman/cosensor-em.json : COSensor-EM ✔️

  • develco/zhemi101_external_meter_interface.json : Electricity meter interface (ZHEMI101) ✔️

  • ikea/rodret_dimmer.json : Rodret Wireless Dimmer (E2201) ✔️

  • icasa/ICZB-IW21SW.json : Zigbee On/Off Switch PRO ✔️

  • ikea/parasoll_open_close_sensor.json : Parasoll door/window sensor (E2013) ✔️

  • legrand/cable_outlet.json : Cable outlet 3000W (064879) ➰ (unvalidated)

  • ikea/tradfri_on_off_switch_old_fw.json : Tradfri on/off switch (E1743) ✔️

  • linkind/ZBT-CCTLight-D0106.json : A60 LED Tunable White Bulb 800 lumen (D0106) ✔️

  • linkind/ZBT-CCTLight-M3500107.json : 4.8W GU10 Bulb Dimmable & Tunable (M3500107) ✔️

  • nedis/nedis_zbsm10wt_motion_sensor.json : Zigbee motion sensor (ZBSM10WT) ✔️

  • mli/tint_gu10_spot_zbt-colortemperature.json : Tint GU10 spot ZBT-ColorTemperature ✔️

  • sengled/e1d-g73.json : Smart window and door sensor (E1D-G73) ✔️

  • sonoff/snzb-04_open_close_sensor.json : Open/close sensor (DS01) ✔️

  • sonoff/trvzb-thermostat.json : Thermostat (TRVZB) ✔️

  • tapestry/tapestry_presence_z1.json : Presence Z1 (THPZ1) ✔️

  • terncy/terncy_sd01.json : Smart dial (TERNCY-SD01) ✔️

  • third_reality/3RMS16BZ_motion_sensor.json : Motion Sensor, Pet Friendly (3RMS16BZ) ✔️

  • third_reality/3RWS18BZ_water_sensor.json : Water leak sensor (3RWS18BZ) ✔️

  • tuya/_TZ3000_TS0201_temp_hum_sensor.json : Temperature and humidity sensor (TS0201) ✔️

  • tuya/_TZ3000_TS0210_vibration_sensor.json : Vibration sensor (TS0210) ✔️

  • tuya/_TZ3000_i8jfiezr_temp_hum_sensor.json : Temperature and humidity sensor (TS0201) ✔️

  • tuya/_TZB000_42ha4rsc_window_blinds.json : Window blinds (TS030F) ✔️

  • tuya/_TZE200_TS0601_humidity_temp.json : Temperature humidity sensor (TS0601) ✔️

  • tuya/_TZE200_TS0601_mmWave_Radar.json : 2.4GHz mmWave radar with LED (TS0601) ✔️

  • tuya/_TZE200_TS0601_humidity_temperature.json : Temperature humidity sensor (TS0601) ✔️

  • tuya/_TZE200_TS0601_trv.json : Thermostat TRV (TS0601) ✔️

  • tuya/_TZE200_bjawzodf_humidity_temp.json : Tuya multi sensor (TS0601) ✔️

  • tuya/_TZE200_thbr5z34_awow__trv.json : Thermostat TRV (MS-C-4) ✔️

  • wiser/contact_sensor_cct591011_as.json : LK Wiser door and windows sensor (550B1023) ✔️

  • tuya/ih-k009_temp_hum_sensor.json : Temperature and Humidity Sensor (IH-K009) ✔️

  • wiser/dimmer_switch_1Gang.json : Merten Wiser 1 gang dimmer ✔️

  • wiser/dimmer_switch_2Gang.json : Merten Wiser 2 gang dimmer ✔️

  • wiser/fuga_dimmer_switch.json : LK Fuga Wiser Wireless Dimmer (545D6102) ✔️

  • wiser/room_thermostat_cctfr6400.json : Wiser room thermostat (CCTFR6400) ✔️

  • xiaomi/xiaomi_lumi.light.aqcn02_TunableWhite_Bulb.json : LED bulb tunable white (ZNLDP12LM) ✔️

  • xiaomi/xiaomi_mccgq11lm_openclose_sensor.json : Open/close sensor (MCCGQ11LM) ✔️

  • xiaomi/xiaomi_mfkzq01lm_cube.json : Cube (MFKZQ01LM) ✔️

  • xiaomi/xiaomi_qbkg03lm_switch.json : Double rocker switch (QBKG03LM) ✔️

  • xiaomi/xiaomi_rtcgq13lm_presence_sensor.json : High precision motion sensor (RTCGQ13LM) ✔️

  • xiaomi/xiaomi_wrs-r02_h1_switch.json : H1 dual rocker wireless remote switch (WRS-R02) ✔️

  • develco/hmszb_temp_hum_sensor.json : Temperature and humidity sensor (HMSZB-110/HMSZB-120) ✔️

  • xiaomi/xiaomi_wxkg17lm_e1_switch.json : E1 dual rocker wireless switch (WXKG17LM) ✔️

  • xiaomi/xiaomi_wxkg20lm_mini_switch.json : Wireless mini switch (WXKG20LM) ✔️

  • frient/hmszb_temp_hum_sensor.json : Temperature and humidity sensor (HMSZB-110/HMSZB-120) ✔️

  • heiman/HS3AQ_air_quality_sensor.json : Air quality monitor (HS3AQ) ✔️

  • ikea/tradfri_bulb_gu10_ws_400lm.json : Tradfri LED bulb GU10 400lm (LED1737R5) ✔️

  • immax/07048L_smart_plug.json : Neo smart plug (07048L) ✔️

  • lixee/zlinky_tic_historique_mono_base.json : ZLinky_TIC mode historique base ✔️

  • lixee/zlinky_tic_standard_mono_base.json : ZLinky_TIC mode standard base ✔️

  • nedis/nedis_zbds10wt.json : Smoke Sensor ✔️

  • sengled/e1c-nb7.json : Smart plug with power monitoring (E1C-NB7) ✔️

  • sonoff/ck-bl702-swp-01(7020)_plug.json : Smart Plug (eWeLink) ✔️

  • sonoff/swv_smart_water_valve.json : Smart water valve ✔️

  • third_reality/3RSP02028BZ_smart_plug.json : Smart plug (3RSP02028BZ) ✔️

  • tuya/_TZ3000_TS0203_door_sensor.json : Door window contact (TS0203) ✔️

  • tuya/_TZ3210_ncw88jfq_temp-hum-sensor.json : Temperature and humidity sensor ✔️

  • tuya/_TZ3210_up3pngle_TS0205_smoke_sensor.json : Smoke sensor (TS0205) ✔️

  • tuya/_TZ3210_dse8ogfy_fingerbot.json : Adaprox fingerbot (TS0001) ✔️

  • tuya/_TZE200_TS0601_smoke_detector.json : Photoelectric smoke sensor (TS0601) ✔️

  • tuya/ih-f001_door_sensor.json : iH-F001 door window contact ✔️

  • tuya/_TZE200_h4cgnbzg_trv.json : Saswell TRVs (TS0601) ✔️

  • tuya/_TZE204_ac0fhfiq_energy_meter.json : BiDirectional zigbee energy meter (TS0601) ✔️

  • lixee/zlinky_tic_historique_mono_hphc.json : ZLinky_TIC mode historique HPHC ✔️

  • tuya/ts0202_presence_sensor.json : Presence sensor (TS0202) ✔️

  • tuya/rh3040_motion_sensor.json : Motion sensor (RH3040) ✔️

  • xiaomi/xiaomi_mfkzq11lm_t1_cube.json : T1 cube (MFKZQ11LM) ✔️

  • xiaomi/xiaomi_wsdcgq01lm_temp_hum_sensor.json : Temperature and humidity sensor (WSDCGQ01LM) ✔️

  • xiaomi/xiaomi_qbkg04lm_switch.json : Single rocker switch (QBKG04LM) ✔️

  • adeo/ldsenk02f_plug.json : Plug 16A ✔️

  • develco/moszb-141_motion_sensor.json : Motion sensor (MOSZB-141) ✔️

  • develco/emizb-141_electricity_meter_interface_2.json : Electricity meter interface 2 EMIZB-141 ✔️

  • develco/wiszb-121_open_close_sensor.json : Entry sensor (WISZB-121) ✔️

  • dresden_elektronik/scene_switch.json : Multifunctional wireless switch (Scene switch) ✔️

  • frient/emizb-141_electricity_meter_interface_2.json : Electricity meter interface 2 EMIZB-141 ✔️

  • frient/wiszb-121_open_close_sensor.json : Entry sensor (WISZB-121) ✔️

  • ikea/tradfri_bulb_e27_ws_opal_1000lm.json : Tradfri LED bulb E27 1000 lumen, dimmable white spectrum opal white (LED1732G11) ✔️

  • ikea/tradfri_bulb_e14_ws_opal_600lm.json : Tradfri LED bulb E14 600 lumen, dimmable white spectrum opal white (LED1733G7) ✔️

  • heiman/hs2wd-e_smart_siren.json : Sound and flash siren (HS2WD) ✔️

  • ikea/tradfri_motion_sensor.json : Tradfri motion sensor (E1525/E1745) ✔️

  • ikea/tradfribulbe27wsglobeopal1055lm.json : Tradfri LED bulb E27 1055 lumen, dimmable, white spectrum, opal white (LED2003G10) ✔️

  • ikea/tradfribulbe14wscandleopal470lm.json : Tradfri LED bulb E14 470 lumen, wireless dimmable white spectrum/chandelier opal white (LED1949C5) ✔️

  • lidl/hg06875.json : Parkside Smart Watering Timer (HG06875) ✔️

  • lixee/zlinky_tic_histo_tri_hphc.json : ZLinky_TIC mode historique HPHC triphase ✔️

  • osram/cla60_tw.json : Smart+ classic E27 tunable white (4058075816534) ✔️

  • lixee/zlinky_tic_standard_tri_hphc.json : ZLinky_TIC mode standard HPHC triphase ✔️

  • osram/classic_a60_tw.json : Lightify classic A 60 TW ✔️

  • osram/par16_50_tw.json : Lightify PAR16 50 TW ✔️

  • osram/classic_b40_tw.json : Lightify Classic B40 TW ✔️

  • robb_smarrt/rob_200-017-0_plug.json : Smart plug 3680W (ROB_200-017-0) ✔️

  • tuya/_TZ3000_TS0207_water_leak_sensor.json : Wwater leak sensor (TS0207) ✔️

  • tuya/_TZE200_myd45weu_soil_sensor.json : Tuya Soil Sensor (TS0601) ✔️

  • xiaomi/xiaomi_mfkzq12lm_t1_pro_cube.json : T1 pro cube (MFKZQ12LM) ✔️

  • xiaomi/xiaomi_ssm-u02_t1_switch.json : T1 single rocker switch no neutral wire (SSM-U02) ✔️

  • adeo/ldsenk08_door_vibration_sensor.json : Lexman door window sensor with vibration (LDSENK08) ✔️

  • xiaomi/xiaomi_ws-euk02_h1_switch.json : H1 dual rocker switch no neutral wire (WS-EUK02) ✔️

  • centralite/motion_sensor-a.json : Motion Sensor-A ✔️

  • aubess/aubess_plug_TZ3000_hdopuwv6.json : Smart plug 16A EU (TS011F) ✔️

  • heiman/smartplug.json : Metering Plug (HS2SK) ✔️

  • ikea/blind.json : Blinds (FYRTUR/KADRILJ/PRAKTLYSING/TREDANSEN) ✔️

  • ikea/symfonisk_sound_contoller.json : Symfonisk sound controller (E1744) ✔️

  • innr/sp_234.json : Smart plug (SP 234) ✔️

  • innr/sp_120.json : Smart plug (SP 120) ✔️

  • moes/Moes_TZE200_ztvwu4nk_thermostat.json : Thermostat for Water/Gas Boiler (BHT-002) ✔️

  • niko/170-33505_170-33605_smart_socket.json : Smart socket (170-33505/170-33605) ✔️

  • sinope/sp2610zb_smart_switch.json : Smart in-wall outlet US (SP2610ZB) ✔️

  • owon/ac201.json : Split A/C controller (AC201) ✔️

  • third_reality/3RSPE01044BZ_smart_plug.json : Smart plug ✔️

  • tuya/_TZ3000_cehuw1lw_smartplug_EU.json : Standard plug (TS011F) ✔️

  • wiser/fuga_socket_outlet.json : LK Fuga Wiser wireless socket outlet 16A (545D6115) ✔️

  • wiser/socket-outlet-double-16A-connected.json : Elko smart socket double 16A plus PW (EKO09738) ✔️

  • xiaomi/xiaomi_dcm-k01_t2_dual_relay.json : Aqara Dual Relay Module T2 (DCM-K01) ✔️

  • wiser/smart-plug-single-16A.json : Wiser smart plug 16A (CCT711119) ✔️

  • wiser/wall_switch_shutter.json : Wiser Odace roller shutter switch (S520567W) ✔️

  • xiaomi/xiaomi_lumi.airrtc.agl001.json : Smart radiator thermostat E1 (SRTS-A01) ✔️

  • xiaomi/xiaomi_ws-euk01_h1_switch.json : H1 single rocker switch no neutral wire (WS-EUK01) ✔️

  • blitzwolf/bw_shp15_smart_plug.json : Power monitoring 16A 3680W EU plug (BW-SHP15) ✔️

  • xiaomi/xiaomi_wp-p01d_h2_wall_outlet.json : Aqara wall outlet H2 EU (WP-P01D) ✔️

  • blitzwolf/bw_shp13_smart_plug.json : Electricity metering 16A EU plug (BW-SHP13) ✔️

  • develco/aqszb-110_voc_sensor.json : Air quality sensor (AQSZB-110) ✔️

  • develco/splzb-131_smart_plug.json : Smart plug mini type F - Schuko (SPLZB-131) ✔️

  • dresden_elektronik/kobold.json : Smart dimmer switch (Kobold) ✔️

  • elko/thermostat_16_a.json : Connected thermostat elko smart plus 16A (EKO07259) ✔️

  • frient/aqszb-110_voc_sensor.json : Air quality sensor (AQSZB-110) ✔️

  • frient/splzb-131_smart_plug.json : Smart plug mini (SPLZB-131/SPLZB-134/SPLZB-141) ✔️

  • ikea/tradfri_bulb_e14_w_opal_400lm.json : Tradfri LED bulb E12 400 lumen, wireless dimmable warm white, chandelier opal (LED1649C5) ✔️

  • ikea/tradfri_bulb_e27_w_opal_1000lm.json : Tradfri LED bulb E27 1000 lumen, dimmable warm white globe opal white (LED1623G12) ✔️

  • lidl/hg08673.json : SilverCrest smart plug (HG08673) ✔️

  • neo/NAS-WR01B_TS011F.json : Smart plug 16A with power monitoring EU (NAS-WR01B) ✔️

  • philips/lom007_smart_plug.json : Hue smart plug ✔️

  • stelpro/smt402ad.json : Thermostat (SMT402AD) ✔️

  • tuya/_TZ3000_TS011F_smart_plug.json : Smart plug power monitor (TS011F) ✔️

  • tuya/_TZE200_byzdayie_din_enrgy_meter.json : Single phase 65A DIN rail smart energy meter (TS0601) ✔️

  • tuya/_TZ3000_typdpbpg_smart_plug_eu.json : Smart plug EU (TS011F) ✔️

  • tuya/nous_a1z_smart_plug.json : Smart zigbee socket (A1Z) ✔️

  • tuya/_TZE200_hhrtiq0x_nedis_trv.json : Nedis TRV (TS0601) ✔️

  • wiser/itrv_thermostat.json : Wiser radiator thermostat (WV704R0A0902) ✔️

  • xiaomi/xiaomi_jtyj-gd-01lm_smoke_detector.json : Honeywell fire alarm smoke detector (JTYJ-GD-01LM/BW) ✔️

  • xiaomi/xiaomi_jtqj-bf-01lm_gas_leak_detector.json : Honeywell gas leak detector (JTQJ-BF-01LM/BW) ✔️

  • xiaomi/xiaomi_zncz12lm_smart_plug.json : Smart plug (ZNCZ12LM) ✔️

  • develco/wiszb-120_open_close_sensor.json : Entry sensor pro (WISZB-120) ✔️

  • dresden_elektronik/lighting_switch.json : Multifunctional wireless switch (Lighting switch) ✔️

  • frient/wiszb-120_open_close_sensor.json : Entry sensor pro (WISZB-120) ✔️

  • frient/kepzb-110_keypad.json : Wireless keypad (KEPZB-110) ✔️

  • namron/4512737_thermostat.json : Thermostat touch zigbee 16A (4512737/4512738) ✔️

  • xfinity/THK1_keypad.json : Security keypad ✔️

  • xiaomi/lumi_curtain_acn002.json : Roller shade driver E1 (ZNJLBL01LM) ✔️

  • xiaomi/lumi_motion_ac01.json : FP1 human presence sensor (RTCZCGQ11LM) ✔️

  • xiaomi/xiaomi_lumi.relay.c2acn01.json : 2 way control module wireless relay ✔️

  • xiaomi/xiaomi_sp-euc01_smart_plug.json : Smart plug (SP-EUC01) ✔️

  • xiaomi/xiaomi_th-s02d_t1_temp_hum_sensor.json : T1 Temperature and Humidity Sensor (TH-S02D) ✔️

  • bosch/room_thermostat2_230V.json : Room thermostat II 230V (BTH-RM230Z) ✔️

  • xiaomi/xiaomi_wsdcgq11lm_temp_hum_sensor.json : Temperature and humidity sensor (WSDCGQ11LM) ✔️

  • icasa/ICZB-IW11D.json : AC dimmer (ICZB-IW11D) ✔️

  • innr/sp_240.json : Smart plug (SP 240) ✔️

  • namron/5401395_heater.json : Panel heater ✔️

  • xiaomi/lumi_vibration_aq1.json : Vibration sensor (DJT11LM) ✔️

  • xiaomi/xiaomi_rtcgqq11lm_presence_sensor.json : Motion sensor (RTCGQ11LM) ✔️

  • xiaomi/xiaomi_ws-euk04_h1_switch.json : H1 dual rocker switch neutral wire (WS-EUK04) ✔️

  • xiaomi/xiaomi_zncz04lm_smart_plug_v24.json : Smart plug (ZNCZ04LM) ✔️

  • xiaomi/xiaomi_zncz04lm_smart_plug.json : Smart plug (ZNCZ04LM) ✔️

  • bosch/room_thermostat2.json : Room thermostat II (BTH-RM) ✔️

  • ikea/tradfri_driver_30w.json : Tradfri LED Driver for Wireless Control 30W (ICPSHC24-10EU-IL-1/ICPSHC24-10NA-IL-1) ✔️

  • ubisys/h1.json : Heating regulator (H1) ✔️

  • tuya/_TZE200_dwcarsat_air_sensor.json : Smart Air House keeper (TS0601) ✔️

  • ubisys/s1_5501_s1r_5601.json : Power switch (S1 (5501)/S1-R (5601)) ✔️

  • ubisys/s2_5502.json : Power switch (S2 (5502)) ✔️

  • ubisys/s2r_5602.json : Power switch (S2-R (5602)) ✔️

  • xiaomi/xiaomi_ws-euk03_h1_switch.json : H1 single rocker switch neutral wire (WS-EUK03) ✔️

  • develco/smszb-120_smoke_detector.json : Intelligent smoke alarm (SMSZB-120) ✔️

  • develco/heszb-120_heat_detector.json : Intelligent heat alarm (HESZB-120) ✔️

  • frient/heszb-120_heat_detector.json : Intelligent heat alarm (HESZB-120) ✔️

  • frient/smszb-120_smoke_detector.json : Intelligent smoke alarm (SMSZB-120) ✔️

  • xiaomi/xiaomi_ssm-u01_t1_switch.json : T1 single rocker switch with neutral wire (SSM-U01) ✔️

  • bosch/thermostat2.json : Thermostat II (BTH-RA) ✔️

  • ikea/vallhorn_wireless_motion_sensor.json : Vallhorn wireless motion sensor (E2134) ✔️

  • tuya/_TS0601_TZE204_qasjif9e_mmwave_radar.json : Human presence detector ceiling (TS0601) ✔️

  • tuya/_TS0601_TZE204_ijxvkhd0_mmwave_radar.json : Human presence detector wall (TS0601) ✔️

  • tuya/_TZE204_sxm7l9xa_mmwave_radar.json : Tuya human presence detector (TS0601) ✔️

  • xiaomi/lumi_airmonitor_acn01.json : TVOC Air Quality Monitor (VOCKQJK11LM) ✔️

  • fireangel/generic_alarm.json : Zigbee Radio Module (P-LINE) ✔️

  • xiaomi/xiaomi_rtcgq14lm_p1_presence_sensor.json : P1 presence sensor (RTCGQ14LM) ✔️

  • fireangel/co_alarm.json : Zigbee Radio Module (P-LINE) ✔️

  • tuya/ZY-M100_human_breathing_presence.json : MmwRadar Human Presence Detector (TS0601) ✔️

  • fireangel/smoke_alarm.json : Zigbee Radio Module (P-LINE) ✔️

  • tuya/_TZE200_kb5noeto_motion_sensor.json : Tuya PIR 24G Radar Sensor ✔️

  • 3A-Nue/lxt56-ls27lx1.7.json : RGBW LED strip controller (3A12S-15) ✔️

  • greeble/jz-rgbw-z01.json : Extended color light (JZ-RGBW-Z01) ✔️

  • bosch/bmct-slz_shutter_light_control2.json : Light and shutter control II (BMCT-SLZ) ✔️

  • ikea/vindstyrka_air_quality_sensor.json : Vindstyrka air quality sensor (E2112) ✔️

  • sengled/E12-N1E.json : Soft white BR30 bulb (E12-N1E) ✔️

  • ubisys/j1_5502.json : Cover controller (J1 (5502)) ✔️

  • ubisys/j1r_5602.json : Cover controller (J1-R (5602)) ✔️

  • bosch/rfdl-zb-ms_motion_sensor.json : RADION TriTech ZB Wireless Motion Detector ✔️

  • ouellet/OTH4000-ZB.json : Smart thermostat (OTH4000-ZB) ✔️

  • gledopto/floodlight.json : Floodlight ✔️

  • philips/light_zb3_white.json : Hue white light ✔️

  • sunricher/SR-ZG9030A-MW.json : Ceiling mount microwave occupancy sensor (SR-ZG9030A-MW) ✔️

  • sinope/th1124zb.json : Smart thermostat for electric heating (TH1123ZB/TH1124ZB) ✔️

  • ubisys/ld6.json : Lighting driver (LD6) ✔️

  • tuya/_TZ3000_TS004F_smart_knob.json : Smart Knob (TS004F) ✔️

  • frient/moszb-154_motion_sensor.json : Motion sensor pro (MOSZB-154) ✔️

  • ikea/tradfri_bulb_e27_ws_opal_980lm.json : Tradfri LED bulb E26/E27 980 lumen, dimmable, white spectrum, opal white (LED1545G12) ✔️

  • ledvance/ledvance_cla60_rgbw_z3.json : CLA60 RGBW Z3 ✔️

  • osram/classic_a60_rgbw.json : Lightify classic A60 RGBW ✔️

  • dresden_elektronik/fls_pp3.json : Wireless electronic ballast power-PWM (FLS-PP) ✔️

  • develco/moszb-140_motion_sensor.json : Motion sensor (MOSZB-130/MOSZB-140) ✔️

  • osram/lightify_indoor_flex_rgbw.json : LIGHTIFY Indoor Flex RGBW ✔️

  • owon/PIR313-E_sensor_multi.json : Motion multi sensor (PIR313) ✔️

  • frient/moszb-140_motion_sensor.json : Motion sensor pro (MOSZB-140) ✔️

  • icasa/ICZB-IW21D.json : Zigbee Dimmer PRO ✔️

  • ikea/starkvind_air_purifier.json : Starkvind Air purifier (E2006/E2007) ✔️

  • philips/light_zll_white_ambiance.json : Hue white ambiance light ✔️

  • siglis/zigfred_uno_wired_switch.json : Wall switch (zigfred uno) ✔️

  • ubisys/d1_5503_d1r_5603.json : Universal dimmer (D1 (5503)/D1-R (5603)) ✔️

  • frient/moszb-153_motion_sensor.json : Motion sensor 2 - Pet (MOSZB-153) ✔️

  • fantem/zb003-x_multi_sensor.json : Multi sensor 4 in 1 (ZB003-X) ✔️

  • siglis/zigfred_plus_wired_switch.json : 4x dimmer switch (zigfred plus) ✔️

  • ikea/ormanas_led_strip.json : Ormanas LED lighting strip (L2112) ✔️

  • mli/zbt-extendedcolor.json : Tint GU10 spot ✔️

  • ikea/tradfri_bulb_e27_cws_opal_600lm.json : Tradfri LED bulb E27 600lm, dimmable colour and white spectrum opal white (LED1624G9) ✔️

  • xiaomi/lumi_light_acn032.json : Ceiling Light T1M (CL-L02D) ✔️

  • iluminize/led_controller_multi_5.cct.json : LED Controller Multi 5 (CCT mode) ✔️

  • iluminize/led_controller_multi_5.rgbcct.json : LED Controller Multi 5 (RGBCCT mode) ✔️

  • iluminize/led_controller_multi_5.rgbw.json : LED Controller Multi 5 (RGBW mode) ✔️

  • danfoss/etrv0100_thermostat.json : Ally radiator thermostat (014G2461) ✔️

  • philips/light_zb3_white_ambiance.json : Hue white ambiance light ✔️

  • philips/light_zll_A.json : Hue color ambiance light ✔️

  • xiaomi/lumi_light_acn132.json : LED strip T1 (LGYCDD01LM) ✔️

  • ikea/tradfri_bulb_cws_A.json : Tradfri LED bulb E27 806 lumen CWS and GU10 345 lumen CWS (LED2004G8/LED2110R3) ✔️

  • dresden_elektronik/hive.json : Portable ambient light (Phoscon Hive) ✔️

  • philips/light_zll_B.json : Hue white and color ambiance light ✔️

  • philips/light_zb3_C.json : Hue white and color ambiance light ✔️

  • philips/light_zb3_C_festavia.json : Hue festavia string lights ✔️

  • philips/light_zll_C.json : Hue white and color ambiance light ✔️

  • philips/light_zb3_C_gradient.json : Hue white and color ambiance gradient light ✔️

Validation

Tip

Everything is fine !

🕒 Updated for commit 58dbc8c

@ebaauw ebaauw requested review from SwoopX and manup October 18, 2024 14:54
@ebaauw ebaauw changed the title Refactor lightToMap() and semsorToMap() Refactor lightToMap() and sensorToMap() Oct 18, 2024
- Include top-level key in `ApiAttribute`;
- Optional `event` parameter to use separate `attr` submap.
- Optional `event` parameter to handle web socket notifications;
- `LightNode *` parameter is no longer `const`, since the `needPushChange` property of the underlying resource items will be cleared.
Leverage `lightToMap()` in `handleLightEvent()`.
@ebaauw ebaauw marked this pull request as draft October 20, 2024 11:21
Oops, forgot to trigger update of group state.
@ebaauw ebaauw marked this pull request as ready for review October 20, 2024 12:24
@manup
Copy link
Member

manup commented Oct 28, 2024

Thanks a lot for the PR. From a first coarse look the direction where this goes is pretty good. I don't understand every detail yet and need to dig deeper, but if we can build outgoing API data with less item/device specific C++ code that's wonderful.

Ideally using logic and structure from the dynamic objects which are described in DDF items. Looking at the PR and toApi() function the JSON files describing DDF items could be extended in future:

Complex "virtual" items: like state/xy could be described right in the DDF item JSON file as expression:

{
  "schema": "resourceitem1.schema.json",
  "id": "state/xy",
  "datatype": "Array",
  "to_api_expr": "[ R.item('state/x').val, R.item('state/y').val ];" 
}

Where the default only returns .val of the current item.

A handler of these would further reduce the needPushChange() and clearNeedPush() calls. The implicit task that state/xy depends on state/x and state/y and should be pushed if one of those is "dirty" could be handled automatically without extra noise in JSON description.

Change data type to Double.
Change data type to Double.
Change data type to Double.
Change data type to Double.
Fix range and description
For IKEA INSPELNING smart plug, that actually changes the divisor based on the measured power.
Change data type to Double.
Change data type to Double.
Change data type to Double.
Fix range and description
Change data type to Double.
Add RStatePowerDivisor
Add RStatePowerDivisor;
Change data type to Double for:
- RStateCurrent and variants;
- RStatePressure and bis;
- RStatePower;
- RStateVoltage.
Fix validation error.
@ebaauw
Copy link
Collaborator Author

ebaauw commented Nov 8, 2024

I resolved conflicts and validation errors after recent merges of other PRs. And I double-checked that this PR still compiles.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants