Add configuration URL to RainMachine (#57732)

pull/57984/head
Aaron Bach 2021-10-15 21:33:26 -06:00 committed by GitHub
parent 34fee4ba60
commit f13eeee969
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 6 deletions

View File

@ -323,6 +323,7 @@ class RainMachineEntity(CoordinatorEntity):
def __init__( def __init__(
self, self,
entry: ConfigEntry,
coordinator: DataUpdateCoordinator, coordinator: DataUpdateCoordinator,
controller: Controller, controller: Controller,
description: EntityDescription, description: EntityDescription,
@ -332,6 +333,7 @@ class RainMachineEntity(CoordinatorEntity):
self._attr_device_info = { self._attr_device_info = {
"identifiers": {(DOMAIN, controller.mac)}, "identifiers": {(DOMAIN, controller.mac)},
"configuration_url": f"https://{entry.data[CONF_IP_ADDRESS]}:{entry.data[CONF_PORT]}",
"connections": {(dr.CONNECTION_NETWORK_MAC, controller.mac)}, "connections": {(dr.CONNECTION_NETWORK_MAC, controller.mac)},
"name": str(controller.name), "name": str(controller.name),
"manufacturer": "RainMachine", "manufacturer": "RainMachine",

View File

@ -131,7 +131,7 @@ async def async_setup_entry(
async_add_entities( async_add_entities(
[ [
async_get_sensor(description.api_category)(controller, description) async_get_sensor(description.api_category)(entry, controller, description)
for description in BINARY_SENSOR_DESCRIPTIONS for description in BINARY_SENSOR_DESCRIPTIONS
] ]
) )

View File

@ -114,7 +114,7 @@ async def async_setup_entry(
async_add_entities( async_add_entities(
[ [
async_get_sensor(description.api_category)(controller, description) async_get_sensor(description.api_category)(entry, controller, description)
for description in SENSOR_DESCRIPTIONS for description in SENSOR_DESCRIPTIONS
] ]
) )

View File

@ -157,9 +157,9 @@ async def async_setup_entry(
entities: list[RainMachineProgram | RainMachineZone] = [ entities: list[RainMachineProgram | RainMachineZone] = [
RainMachineProgram( RainMachineProgram(
entry,
programs_coordinator, programs_coordinator,
controller, controller,
entry,
RainMachineSwitchDescription( RainMachineSwitchDescription(
key=f"RainMachineProgram_{uid}", name=program["name"], uid=uid key=f"RainMachineProgram_{uid}", name=program["name"], uid=uid
), ),
@ -169,9 +169,9 @@ async def async_setup_entry(
entities.extend( entities.extend(
[ [
RainMachineZone( RainMachineZone(
entry,
zones_coordinator, zones_coordinator,
controller, controller,
entry,
RainMachineSwitchDescription( RainMachineSwitchDescription(
key=f"RainMachineZone_{uid}", name=zone["name"], uid=uid key=f"RainMachineZone_{uid}", name=zone["name"], uid=uid
), ),
@ -191,13 +191,13 @@ class RainMachineSwitch(RainMachineEntity, SwitchEntity):
def __init__( def __init__(
self, self,
entry: ConfigEntry,
coordinator: DataUpdateCoordinator, coordinator: DataUpdateCoordinator,
controller: Controller, controller: Controller,
entry: ConfigEntry,
description: RainMachineSwitchDescription, description: RainMachineSwitchDescription,
) -> None: ) -> None:
"""Initialize a generic RainMachine switch.""" """Initialize a generic RainMachine switch."""
super().__init__(coordinator, controller, description) super().__init__(entry, coordinator, controller, description)
self._attr_is_on = False self._attr_is_on = False
self._data = coordinator.data[self.entity_description.uid] self._data = coordinator.data[self.entity_description.uid]