@@ -583,22 +583,33 @@ def _version_check(self, min_version: str, max_version: str = "") -> bool:
583583
584584 # Self production HTTP Posting
585585
586- async def self_production (self , grid : int , solar : int , invert : bool = True ) -> None :
586+ async def self_production (
587+ self , grid : int | None = None , solar : int | None = None , invert : bool = True
588+ ) -> None :
587589 """Send pushed sensor data to self-prodcution."""
588590 if not self ._version_check ("4.0.0" ):
589591 _LOGGER .debug ("Feature not supported for older firmware." )
590592 raise UnsupportedFeature
591593
592594 # Invert the sensor -import/+export
593- if invert :
595+ if invert and grid is not None :
594596 grid = grid * - 1
595597
596598 url = f"{ self .url } status"
597- data = {"solar" : solar , "grid_ie" : grid }
599+ data = {}
600+
601+ # Prefer grid sensor data
602+ if grid is not None :
603+ data = {"grid_ie" : grid }
604+ elif solar is not None :
605+ data = {"solar" : solar }
598606
599- _LOGGER .debug ("Posting self-production: %s" , data )
600- response = await self .process_request (url = url , method = "post" , data = data )
601- _LOGGER .debug ("Self-production response: %s" , response )
607+ if not data :
608+ _LOGGER .info ("No sensor data to send to device." )
609+ else :
610+ _LOGGER .debug ("Posting self-production: %s" , data )
611+ response = await self .process_request (url = url , method = "post" , data = data )
612+ _LOGGER .debug ("Self-production response: %s" , response )
602613
603614 @property
604615 def hostname (self ) -> str :
0 commit comments