Skip to content

Commit

Permalink
hass 2023.5
Browse files Browse the repository at this point in the history
Signed-off-by: Travis Glenn Hansen <travisghansen@yahoo.com>
  • Loading branch information
travisghansen committed Apr 30, 2023
1 parent 741af76 commit b183045
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# v0.6.1

Released 2023-04-30

- minor fixes
- support for hass 2023.5

# v0.6.0

Released 2023-02-05
Expand Down
13 changes: 6 additions & 7 deletions custom_components/pfsense/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.entity_registry import async_get as async_get_ent_reg
from homeassistant.helpers.entity_registry import async_get
from homeassistant.helpers.restore_state import RestoreEntity
from homeassistant.helpers.update_coordinator import (
CoordinatorEntity,
Expand Down Expand Up @@ -347,16 +347,16 @@ def update(self, opts={}):
] = self._are_notices_pending()
new_state["notices"]["pending_notices"] = self._get_notices()

lease_stats = {"total": 0, "online": 0, "offline": 0}
lease_stats = {"total": 0, "online": 0, "idle_offline": 0}
for lease in new_state["dhcp_leases"]:
if "act" in lease.keys() and lease["act"] == "expired":
continue

lease_stats["total"] += 1
if "online" in lease.keys():
if ("active" or "online") in lease["online"]:
if lease["online"] in ["active", "online"]:
lease_stats["online"] += 1
if "offline" in lease["online"]:
if lease["online"] in ["offline", "idle/offline", "idle"]:
lease_stats["idle_offline"] += 1

new_state["dhcp_stats"]["leases"] = lease_stats
Expand Down Expand Up @@ -581,9 +581,8 @@ def process_entities(self):
# self.entity_unique_ids.remove(entity_unique_id)
# del self.entities[entity_unique_id]

@callback
def async_remove_entity(self, entity):
registry = async_get_ent_reg(self.hass)
async def async_remove_entity(self, entity):
registry = await async_get(self.hass)
if entity.entity_id in registry.entities:
registry.async_remove(entity.entity_id)

Expand Down
5 changes: 5 additions & 0 deletions custom_components/pfsense/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ async def async_step_user(self, user_input=None):
CONF_VERIFY_SSL: verify_ssl,
},
)

# can be when using http instead of https
# 2022-08-16 09:43:17.803 ERROR (MainThread) [custom_components.opnsense.config_flow] Unexpected err=RemoteDisconnected('Remote end closed connection without response'), type(err)=<class 'http.client.RemoteDisconnected'>
# when proper permissions are not setup
# 2022-08-16 09:43:26.680 ERROR (MainThread) [custom_components.opnsense.config_flow] Unexpected err=TypeError('string indices must be integers'), type(err)=<class 'TypeError'>
except InvalidURL:
errors["base"] = "invalid_url_format"
except xmlrpc.client.Fault as err:
Expand Down

0 comments on commit b183045

Please sign in to comment.