@@ -507,6 +507,60 @@ def update_from_dict(self, data: dict[str, Any]) -> None:
507507 self .dhw_cm_switch = process_dict (data , "switches" , "dhw_cm_switch" )
508508
509509
510+ @dataclass (kw_only = True )
511+ class Group (DeviceBase ):
512+ """Group class covering switch-groups, pump-groups, for Adam and Stretch."""
513+
514+ members : list [str ] | None = None
515+ sensors : GroupSensors
516+ switches : GroupSwitch
517+
518+ def __init__ (self ) -> None :
519+ """Init Group class and inherited functions."""
520+ super ().__init__ ()
521+ self .sensors = GroupSensors ()
522+ self .switches = GroupSwitch ()
523+
524+ def update_from_dict (self , data : dict [str , Any ]) -> None :
525+ """Update this Group object with data from a dictionary."""
526+ super ().update_from_dict (data )
527+ self .members = process_key (data , "members" )
528+ self .sensors .update_from_dict (data )
529+ self .switches .update_from_dict (data )
530+
531+
532+ @dataclass (kw_only = True )
533+ class GroupSensors :
534+ """Group sensors class."""
535+
536+ electricity_consumed : float | None = None
537+ electricity_produced : float | None = None
538+ temperature : float | None = None
539+
540+ def update_from_dict (self , data : dict [str , Any ]) -> None :
541+ """Update this GroupSensors object with data from a dictionary."""
542+ self .electricity_consumed = process_dict (
543+ data , "sensors" , "electricity_consumed"
544+ )
545+ self .electricity_produced = process_dict (
546+ data , "sensors" , "electricity_produced"
547+ )
548+ self .temperature = process_dict (data , "sensors" , "temperature" )
549+
550+
551+ @dataclass (kw_only = True )
552+ class GroupSwitch :
553+ """Group switch class."""
554+
555+ lock : bool | None = None
556+ relay : bool | None = None
557+
558+ def update_from_dict (self , data : dict [str , Any ]) -> None :
559+ """Update this GroupSwitch object with data from a dictionary."""
560+ self .lock = process_dict (data , "switches" , "lock" )
561+ self .relay = process_dict (data , "switches" , "relay" )
562+
563+
510564@dataclass (kw_only = True )
511565class Plug (DeviceBase ):
512566 """Plug data class covering Plugwise Adam/Stretch and Aqara Plugs, and generic ZigBee type Switches."""
@@ -574,6 +628,7 @@ class PlugwiseData:
574628 - Gateway Adam
575629 - Climate device: OnOff or Opentherm
576630 - Zones (1 to many) with thermostatic and energy sensors summary, with thermostat setpoint- and mode-, preset- & schedule-setter
631+ - Groups - switching type
577632 - Single devices (appliances) assigned to a Zone, or not
578633 - Anna (wired thermostat)
579634 - Emma Pro wired (wired thermostat)
@@ -603,43 +658,40 @@ class PlugwiseData:
603658
604659 - Gateway Stretch (legacy)
605660 - Single devices (Zigbee)
661+ - Groups: switching and reporting types
606662 - ??
607663 """
608664
609665 gateway : Gateway = Gateway ()
610666 climate_device : ClimateDevice | None
611- zones : list [Zone ] | None
612- thermostats : list [Thermostat ] | None
667+ groups : list [Group ] | None
613668 plugs : list [Plug ] | None
614669 p1_dsmr : SmartEnergyMeter | None
670+ thermostats : list [Thermostat ] | None
671+ zones : list [Zone ] | None
615672
616673 def __init__ (self , data : Any ) -> None :
617674 """Initialize PlugwiseData class."""
618675 self .climate_device = None
619- self .p1_dsmr = None
676+ self .groups = None
620677 self .plugs = None
678+ self .p1_dsmr = None
621679 self .thermostats = None
622680 self .zones = None
623681
624682 for _ , device in data .items ():
625683 if device ["dev_class" ] == "gateway" :
626684 self .gateway .update_from_dict (device )
685+ if device ["dev_class" ] in ("pumping" , "report" , "switching" ):
686+ if self .groups is None :
687+ self .groups = []
688+ group = Group ()
689+ group .update_from_dict (device )
690+ self .groups .append (group )
627691 if device ["dev_class" ] == "heater_central" :
628692 if self .climate_device is None :
629693 self .climate_device = ClimateDevice ()
630694 self .climate_device .update_from_dict (device )
631- if device ["dev_class" ] == "climate" :
632- if self .zones is None :
633- self .zones = []
634- zone = Zone ()
635- zone .update_from_dict (device )
636- self .zones .append (zone )
637- if device ["dev_class" ] in ZONE_THERMOSTATS :
638- if self .thermostats is None :
639- self .thermostats = []
640- thermostat = Thermostat ()
641- thermostat .update_from_dict (device )
642- self .thermostats .append (thermostat )
643695 if device ["dev_class" ].endswith ("_plug" ):
644696 if self .plugs is None :
645697 self .plugs = []
@@ -650,6 +702,18 @@ def __init__(self, data: Any) -> None:
650702 if self .p1_dsmr is None :
651703 self .p1_dsmr = SmartEnergyMeter ()
652704 self .p1_dsmr .update_from_dict (device )
705+ if device ["dev_class" ] in ZONE_THERMOSTATS :
706+ if self .thermostats is None :
707+ self .thermostats = []
708+ thermostat = Thermostat ()
709+ thermostat .update_from_dict (device )
710+ self .thermostats .append (thermostat )
711+ if device ["dev_class" ] == "climate" :
712+ if self .zones is None :
713+ self .zones = []
714+ zone = Zone ()
715+ zone .update_from_dict (device )
716+ self .zones .append (zone )
653717
654718 def update_from_dict (self , data : dict [str , Any ]) -> None :
655719 """Update the status object with data received from the Plugwise API."""
0 commit comments