8000 Add "Push Flow Meter Data" service to RainMachine and bump regenmaschine to 2022.10.0 by shbatm · Pull Request #80890 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions homeassistant/components/rainmachine/__init__.py
10000
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CONF_PASSWORD,
CONF_PORT,
CONF_SSL,
CONF_UNIT_OF_MEASUREMENT,
Platform,
)
from homeassistant.core import HomeAssistant, ServiceCall, callback
Expand Down Expand Up @@ -79,9 +80,19 @@
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))
Expand All @@ -91,6 +102,7 @@
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"
Expand All @@ -109,6 +121,15 @@
}
)

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,
Expand Down Expand Up @@ -320,6 +341,17 @@ async def async_pause_watering(call: ServiceCall, controller: Controller) -> Non
"""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
Expand Down Expand Up @@ -378,6 +410,11 @@ async def async_unrestrict_watering(
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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/rainmachine/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
31 changes: 31 additions & 0 deletions homeassistant/components/rainmachine/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: >-
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
0