1616import logging
1717import time
1818from typing import Any
19+ from warnings import deprecated , warn
1920import zlib
2021
2122import httpx
@@ -189,9 +190,9 @@ class Current:
189190 grid_use : float
190191 home_load : float
191192 battery_soc : float
192- switch_1_load : float
193- switch_2_load : float
194- v2l_use : float
193+ switch_1_load : float # deprecated
194+ switch_2_load : float # deprecated
195+ v2l_use : float # deprecated
195196 grid_status : GridStatus
196197
197198
@@ -206,10 +207,10 @@ class Totals:
206207 solar : float
207208 generator : float
208209 home_use : float
209- switch_1_use : float
210- switch_2_use : float
211- v2l_export : float
212- v2l_import : float
210+ switch_1_use : float # deprecated
211+ switch_2_use : float # deprecated
212+ v2l_export : float # deprecated
213+ v2l_import : float # deprecated
213214
214215
215216@dataclass
@@ -351,6 +352,7 @@ def payload(self, gateway) -> dict:
351352 }
352353
353354
355+ @deprecated ("use SmartCircuits instead" )
354356class SwitchState (tuple [bool | None , bool | None , bool | None ]):
355357 """Represents the state of the smart switches connected to the FranklinWH gateway.
356358
@@ -679,6 +681,7 @@ async def get_accessories(self):
679681 # {"code":200,"message":"Query success!","result":[],"success":true,"total":0}
680682 return (await self ._get (url ))["result" ]
681683
684+ @deprecated ("use get_smart_circuits() instead" )
682685 async def get_smart_switch_state (self ) -> SwitchState :
683686 """Get the current state of the smart switches."""
684687 # TODO(richo) This API is super in flux, both because of how vague the
@@ -690,6 +693,7 @@ async def get_smart_switch_state(self) -> SwitchState:
690693 switches = [x == 1 for x in status ["pro_load" ]]
691694 return SwitchState (switches )
692695
696+ @deprecated ("use set_circuit() instead" )
693697 async def set_smart_switch_state (self , state : SwitchState ):
694698 """Set the state of the smart circuits.
695699
@@ -736,6 +740,7 @@ async def _status(self):
736740 return json .loads (data )
737741
738742 # Sends a 311 which appears to be a more specific switch command
743+ @deprecated ("use get_smart_circuits() or get_smart_circuits_enhanced() instead" )
739744 @time_cached ()
740745 async def _switch_status (self ):
741746 payload = self ._build_payload (311 , {"opt" : 0 , "order" : self .gateway })
@@ -744,6 +749,7 @@ async def _switch_status(self):
744749
745750 # Sends a 353 which grabs real-time smart-circuit load information
746751 # https://github.com/richo/homeassistant-franklinwh/issues/27#issuecomment-2714422732
752+ @deprecated ("use get_smart_circuits_enhanced() instead" )
747753 @time_cached ()
748754 async def _switch_usage (self ):
749755 payload = self ._build_payload (353 , {"opt" : 0 , "order" : self .gateway })
@@ -782,6 +788,11 @@ async def get_stats(self) -> Stats:
782788
783789 This includes instantaneous measurements for current power, as well as totals for today (in local time)
784790 """
791+ warn (
792+ "switch statistics are deprecated from get_stats(), use get_smart_circuits_enhanced() instead" ,
793+ DeprecationWarning ,
794+ stacklevel = 2 ,
795+ )
785796 tasks = [f () for f in [self .get_composite_info , self ._switch_usage ]]
786797 info , sw_data = await asyncio .gather (* tasks )
787798 data = info ["runtimeData" ]
0 commit comments