Skip to content

Commit

Permalink
0.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
gvigroux committed Jan 25, 2025
1 parent 236574b commit 8728df8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
30 changes: 20 additions & 10 deletions custom_components/freebox_home/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,20 @@ def __init__(self, hass, router, node) -> None:
self._invert_entity_id = entity.entity_id



def get_corrected_state(self, value):
def get_invert_status(self):
if(self._invert_entity_id == None):
return value
if( value == None ):
return value
return False
state = self._hass.states.get(self._invert_entity_id)
if( state == None ):
return False
if( state.state == "on" ):
return True
return False

def get_corrected_state(self, value):
if( value == None ):
return value
if( state.state == "off" ):
if( self.get_invert_status() ):
if( DUMMY ):
_LOGGER.error("Value converted from " + str(value) + " to " + str(100 - value))
return 100 - value
Expand Down Expand Up @@ -165,22 +169,28 @@ async def async_set_cover_position(self, position, **kwargs):

async def async_open_cover(self, **kwargs):
"""Open cover."""
await self.set_home_endpoint_value(self._command_up, {"value": self.get_corrected_state(0)})
if( self.get_invert_status() == False ):
await self.set_home_endpoint_value(self._command_up, {"value": 0})
else:
await self.set_home_endpoint_value(self._command_down, {"value": 100})
self._current_state = 100

async def async_close_cover(self, **kwargs):
"""Close cover."""
await self.set_home_endpoint_value(self._command_down, {"value": self.get_corrected_state(100)})
if( self.get_invert_status() == True ):
await self.set_home_endpoint_value(self._command_up, {"value": 0})
else:
await self.set_home_endpoint_value(self._command_down, {"value": 100})
self._current_state = 0

async def async_stop_cover(self, **kwargs):
"""Stop cover."""
await self.set_home_endpoint_value(self._command_stop, {"value": None})
self._current_state = None
self._current_state = 50

async def async_update(self):
"""Get the state & name and update it."""
if( DUMMY ):
if( self._id >= 1000 ) and (DUMMY):
_LOGGER.error("Current state: " + str(self._current_state) + " Freebox: " + str(self.get_corrected_state(self._current_state)))
else:
self._current_state = self.get_corrected_state(await self.get_home_endpoint_value(self._command_state))
2 changes: 1 addition & 1 deletion custom_components/freebox_home/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
"iot_class": "local_polling",
"issue_tracker": "https://github.com/gvigroux/freebox_home/issues",
"requirements": ["freebox-api"],
"version": "0.8.2",
"version": "0.8.3",
"zeroconf": ["_fbx-api._tcp.local."]
}
4 changes: 2 additions & 2 deletions custom_components/freebox_home/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def update_all(self, now: Optional[datetime] = None) -> None:
"""Update all nodes"""
try:
fbx_nodes: Dict[str, Any] = await self._api.home.get_home_nodes()

_LOGGER.debug("DUMP Nodes" + str(fbx_nodes))

except InsufficientPermissionsError as error:
_LOGGER.error("InsufficientPermissionsError: You need to browse http://mafreebox.freebox.fr/#Fbx.os.app.settings.Accounts and grant the access policy: \"Gestion de l'alarme et maison connectée\"")
Expand All @@ -58,7 +58,7 @@ async def update_all(self, now: Optional[datetime] = None) -> None:
self.nodes[fbx_node["id"]] = fbx_node

if( DUMMY ):
fbx_node = json.loads('{"adapter":1000,"area":29,"category":"shutter","group":{"label":"Chambre"},"id":1000,"label":"Volet Chambre Garage","name":"node_25","props":{"Address":5187680,"ArcId":9},"show_endpoints":[{"category":"","ep_type":"slot","id":0,"label":"Consigne d\'ouverture","name":"position_set","ui":{"access":"w","display":"slider","icon_url":"/resources/images/home/pictos/volet_3.png","range":[0,100],"unit":"%"},"value":0,"value_type":"int","visibility":"normal"},{"category":"","ep_type":"slot","id":1,"label":"Stop","name":"stop","ui":{"access":"w","display":"button"},"value":null,"value_type":"void","visibility":"normal"},{"category":"","ep_type":"slot","id":2,"label":"Toggle","name":"toggle","ui":{"access":"w","display":"button"},"value":null,"value_type":"void","visibility":"normal"},{"category":"","ep_type":"signal","id":4,"label":"Consigne d\'ouverture","name":"position_set","refresh":2000,"ui":{"access":"r","display":"slider","icon_url":"/resources/images/home/pictos/volet_3.png","range":[0,100],"unit":"%"},"value":0,"value_type":"int","visibility":"normal"},{"category":"","ep_type":"signal","id":5,"label":"État","name":"state","refresh":2000,"ui":{"access":"r","display":"text"},"value":50,"value_type":"string","visibility":"normal"}],"signal_links":[],"slot_links":[],"status":"active","type":{"abstract":false,"endpoints":[{"ep_type":"slot","id":0,"label":"Consigne d\'ouverture","name":"position_set","value_type":"int","visiblity":"normal"},{"ep_type":"slot","id":1,"label":"Stop","name":"stop","value_type":"void","visiblity":"normal"},{"ep_type":"slot","id":2,"label":"Toggle","name":"toggle","value_type":"void","visiblity":"normal"},{"ep_type":"slot","id":3,"label":"Consigne d\'ouverture","name":"position","value_type":"int","visiblity":"normal"},{"ep_type":"signal","id":4,"label":"Consigne d\'ouverture","name":"position_set","param_type":"void","value_type":"int","visiblity":"normal"},{"ep_type":"signal","id":5,"label":"État","name":"state","param_type":"void","value_type":"string","visiblity":"normal"}],"generic":false,"icon":"/resources/images/home/pictos/volet_3.png","inherit":"node::ios","label":"Volet roulant","name":"node::ios::2","params":{},"physical":true}}')
fbx_node = json.loads('{"adapter":1000,"area":29,"category":"shutter","group":{"label":"Chambre"},"id":1000,"label":"Volet Chambre","name":"node_25","props":{"Address":5187680,"ArcId":9},"show_endpoints":[{"category":"","ep_type":"slot","id":0,"label":"Consigne d\'ouverture","name":"position_set","ui":{"access":"w","display":"slider","icon_url":"/resources/images/home/pictos/volet_3.png","range":[0,100],"unit":"%"},"value":0,"value_type":"int","visibility":"normal"},{"category":"","ep_type":"slot","id":1,"label":"Stop","name":"stop","ui":{"access":"w","display":"button"},"value":null,"value_type":"void","visibility":"normal"},{"category":"","ep_type":"slot","id":2,"label":"Toggle","name":"toggle","ui":{"access":"w","display":"button"},"value":null,"value_type":"void","visibility":"normal"},{"category":"","ep_type":"signal","id":4,"label":"Consigne d\'ouverture","name":"position_set","refresh":2000,"ui":{"access":"r","display":"slider","icon_url":"/resources/images/home/pictos/volet_3.png","range":[0,100],"unit":"%"},"value":0,"value_type":"int","visibility":"normal"},{"category":"","ep_type":"signal","id":5,"label":"État","name":"state","refresh":2000,"ui":{"access":"r","display":"text"},"value":50,"value_type":"string","visibility":"normal"}],"signal_links":[],"slot_links":[],"status":"active","type":{"abstract":false,"endpoints":[{"ep_type":"slot","id":0,"label":"Consigne d\'ouverture","name":"position_set","value_type":"int","visiblity":"normal"},{"ep_type":"slot","id":1,"label":"Stop","name":"stop","value_type":"void","visiblity":"normal"},{"ep_type":"slot","id":2,"label":"Toggle","name":"toggle","value_type":"void","visiblity":"normal"},{"ep_type":"slot","id":3,"label":"Consigne d\'ouverture","name":"position","value_type":"int","visiblity":"normal"},{"ep_type":"signal","id":4,"label":"Consigne d\'ouverture","name":"position_set","param_type":"void","value_type":"int","visiblity":"normal"},{"ep_type":"signal","id":5,"label":"État","name":"state","param_type":"void","value_type":"string","visiblity":"normal"}],"generic":false,"icon":"/resources/images/home/pictos/volet_3.png","inherit":"node::ios","label":"Volet roulant","name":"node::ios::2","params":{},"physical":true}}')
self.nodes[1000] = fbx_node

async def close(self) -> None:
Expand Down

0 comments on commit 8728df8

Please sign in to comment.