mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Fix Watergate Power supply mode description and MQTT/Wifi uptimes (#135085)
This commit is contained in:
parent
38d008bb66
commit
026df07451
@ -90,7 +90,7 @@ DESCRIPTIONS: list[WatergateSensorEntityDescription] = [
|
|||||||
WatergateSensorEntityDescription(
|
WatergateSensorEntityDescription(
|
||||||
value_fn=lambda data: (
|
value_fn=lambda data: (
|
||||||
dt_util.as_utc(
|
dt_util.as_utc(
|
||||||
dt_util.now() - timedelta(microseconds=data.networking.wifi_uptime)
|
dt_util.now() - timedelta(milliseconds=data.networking.wifi_uptime)
|
||||||
)
|
)
|
||||||
if data.networking
|
if data.networking
|
||||||
else None
|
else None
|
||||||
@ -104,7 +104,7 @@ DESCRIPTIONS: list[WatergateSensorEntityDescription] = [
|
|||||||
WatergateSensorEntityDescription(
|
WatergateSensorEntityDescription(
|
||||||
value_fn=lambda data: (
|
value_fn=lambda data: (
|
||||||
dt_util.as_utc(
|
dt_util.as_utc(
|
||||||
dt_util.now() - timedelta(microseconds=data.networking.mqtt_uptime)
|
dt_util.now() - timedelta(milliseconds=data.networking.mqtt_uptime)
|
||||||
)
|
)
|
||||||
if data.networking
|
if data.networking
|
||||||
else None
|
else None
|
||||||
@ -158,7 +158,11 @@ DESCRIPTIONS: list[WatergateSensorEntityDescription] = [
|
|||||||
),
|
),
|
||||||
WatergateSensorEntityDescription(
|
WatergateSensorEntityDescription(
|
||||||
value_fn=lambda data: (
|
value_fn=lambda data: (
|
||||||
PowerSupplyMode(data.state.power_supply.replace("+", "_"))
|
PowerSupplyMode(
|
||||||
|
data.state.power_supply.replace("+", "_").replace(
|
||||||
|
"external_battery", "battery_external"
|
||||||
|
)
|
||||||
|
)
|
||||||
if data.state
|
if data.state
|
||||||
else None
|
else None
|
||||||
),
|
),
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': '2021-01-09T11:59:59+00:00',
|
'state': '2021-01-09T11:59:58+00:00',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_sensor[sensor.sonic_power_supply_mode-entry]
|
# name: test_sensor[sensor.sonic_power_supply_mode-entry]
|
||||||
@ -501,6 +501,6 @@
|
|||||||
'last_changed': <ANY>,
|
'last_changed': <ANY>,
|
||||||
'last_reported': <ANY>,
|
'last_reported': <ANY>,
|
||||||
'last_updated': <ANY>,
|
'last_updated': <ANY>,
|
||||||
'state': '2021-01-09T11:59:59+00:00',
|
'state': '2021-01-09T11:59:57+00:00',
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
|
@ -140,11 +140,11 @@ async def test_power_supply_webhook(
|
|||||||
|
|
||||||
power_supply_change_data = {
|
power_supply_change_data = {
|
||||||
"type": "power-supply-changed",
|
"type": "power-supply-changed",
|
||||||
"data": {"supply": "external"},
|
"data": {"supply": "external_battery"},
|
||||||
}
|
}
|
||||||
client = await hass_client_no_auth()
|
client = await hass_client_no_auth()
|
||||||
await client.post(f"/api/webhook/{MOCK_WEBHOOK_ID}", json=power_supply_change_data)
|
await client.post(f"/api/webhook/{MOCK_WEBHOOK_ID}", json=power_supply_change_data)
|
||||||
|
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
assert hass.states.get(entity_id).state == "external"
|
assert hass.states.get(entity_id).state == "battery_external"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user