Add "Push Flow Meter Data" service to RainMachine and bump regenmaschine to 2022.10.0 (#80890)

This commit is contained in:
shbatm 2022-10-24 14:39:37 -05:00 committed by GitHub
parent f61c010116
commit ac4645a37e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 3 deletions

View file

@ -20,6 +20,7 @@ from homeassistant.const import (
CONF_PASSWORD,
CONF_PORT,
CONF_SSL,
CONF_UNIT_OF_MEASUREMENT,
Platform,
)
from homeassistant.core import HomeAssistant, ServiceCall, callback
@ -79,9 +80,19 @@ CONF_SECONDS = "seconds"
CONF_SOLARRAD = "solarrad"
CONF_TEMPERATURE = "temperature"
CONF_TIMESTAMP = "timestamp"
CONF_UNITS = "units"
CONF_VALUE = "value"
CONF_WEATHER = "weather"
CONF_WIND = "wind"
# Config Validator for Flow Meter Data
CV_FLOW_METER_VALID_UNITS = {
"clicks",
"gal",
"litre",
"m3",
}
# Config Validators for Weather Service Data
CV_WX_DATA_VALID_PERCENTAGE = vol.All(vol.Coerce(int), vol.Range(min=0, max=100))
CV_WX_DATA_VALID_TEMP_RANGE = vol.All(vol.Coerce(float), vol.Range(min=-40.0, max=40.0))
@ -91,6 +102,7 @@ CV_WX_DATA_VALID_PRESSURE = vol.All(vol.Coerce(float), vol.Range(min=60.0, max=1
CV_WX_DATA_VALID_SOLARRAD = vol.All(vol.Coerce(float), vol.Range(min=0.0, max=5.0))
SERVICE_NAME_PAUSE_WATERING = "pause_watering"
SERVICE_NAME_PUSH_FLOW_METER_DATA = "push_flow_meter_data"
SERVICE_NAME_PUSH_WEATHER_DATA = "push_weather_data"
SERVICE_NAME_RESTRICT_WATERING = "restrict_watering"
SERVICE_NAME_STOP_ALL = "stop_all"
@ -109,6 +121,15 @@ SERVICE_PAUSE_WATERING_SCHEMA = SERVICE_SCHEMA.extend(
}
)
SERVICE_PUSH_FLOW_METER_DATA_SCHEMA = SERVICE_SCHEMA.extend(
{
vol.Required(CONF_VALUE): cv.positive_float,
vol.Optional(CONF_UNIT_OF_MEASUREMENT): vol.All(
cv.string, vol.In(CV_FLOW_METER_VALID_UNITS)
),
}
)
SERVICE_PUSH_WEATHER_DATA_SCHEMA = SERVICE_SCHEMA.extend(
{
vol.Optional(CONF_TIMESTAMP): cv.positive_float,
@ -320,6 +341,17 @@ async def async_setup_entry( # noqa: C901
"""Pause watering for a set number of seconds."""
await controller.watering.pause_all(call.data[CONF_SECONDS])
@call_with_controller(update_programs_and_zones=False)
async def async_push_flow_meter_data(
call: ServiceCall, controller: Controller
) -> None:
"""Push flow meter data to the device."""
value = call.data[CONF_VALUE]
if units := call.data.get(CONF_UNIT_OF_MEASUREMENT):
await controller.watering.post_flowmeter(value=value, units=units)
else:
await controller.watering.post_flowmeter(value=value)
@call_with_controller(update_programs_and_zones=False)
async def async_push_weather_data(
call: ServiceCall, controller: Controller
@ -378,6 +410,11 @@ async def async_setup_entry( # noqa: C901
SERVICE_PAUSE_WATERING_SCHEMA,
async_pause_watering,
),
(
SERVICE_NAME_PUSH_FLOW_METER_DATA,
SERVICE_PUSH_FLOW_METER_DATA_SCHEMA,
async_push_flow_meter_data,
),
(
SERVICE_NAME_PUSH_WEATHER_DATA,
SERVICE_PUSH_WEATHER_DATA_SCHEMA,
@ -419,6 +456,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# defined during integration setup:
for service_name in (
SERVICE_NAME_PAUSE_WATERING,
SERVICE_NAME_PUSH_FLOW_METER_DATA,
SERVICE_NAME_PUSH_WEATHER_DATA,
SERVICE_NAME_RESTRICT_WATERING,
SERVICE_NAME_STOP_ALL,

View file

@ -3,7 +3,7 @@
"name": "RainMachine",
"config_flow": true,
"documentation": "https://www.home-assistant.io/integrations/rainmachine",
"requirements": ["regenmaschine==2022.09.2"],
"requirements": ["regenmaschine==2022.10.0"],
"codeowners": ["@bachya"],
"iot_class": "local_polling",
"homekit": {

View file

@ -97,6 +97,37 @@ unpause_watering:
selector:
device:
integration: rainmachine
push_flow_meter_data:
name: Push Flow Meter Data
description: Push Flow Meter data to the RainMachine device.
fields:
device_id:
name: Controller
description: The controller to send flow meter data to
required: true
selector:
device:
integration: rainmachine
value:
name: Value
description: The flow meter value to send
required: true
selector:
number:
min: 0.0
max: 1000000000.0
step: 0.1
mode: box
unit_of_measurement:
name: Unit of Measurement
description: The flow meter units to send
selector:
select:
options:
- "clicks"
- "gal"
- "litre"
- "m3"
push_weather_data:
name: Push Weather Data
description: >-

View file

@ -2147,7 +2147,7 @@ raincloudy==0.0.7
raspyrfm-client==1.2.8
# homeassistant.components.rainmachine
regenmaschine==2022.09.2
regenmaschine==2022.10.0
# homeassistant.components.renault
renault-api==0.1.11

View file

@ -1483,7 +1483,7 @@ radios==0.1.1
radiotherm==2.1.0
# homeassistant.components.rainmachine
regenmaschine==2022.09.2
regenmaschine==2022.10.0
# homeassistant.components.renault
renault-api==0.1.11