Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add required config options for #6
Browse files Browse the repository at this point in the history
pantherale0 committed Jun 20, 2024
1 parent 646b9ef commit c6fcfae
Showing 3 changed files with 70 additions and 9 deletions.
47 changes: 46 additions & 1 deletion custom_components/fuel_prices/config_flow.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
CONF_SCAN_INTERVAL,
)

from .const import DOMAIN, NAME, CONF_AREAS, CONF_SOURCES, CONF_STATE_VALUE
from .const import DOMAIN, NAME, CONF_AREAS, CONF_SOURCES, CONF_STATE_VALUE, CONF_CHEAPEST_SENSORS, CONF_CHEAPEST_SENSORS_COUNT

_LOGGER = logging.getLogger(__name__)

@@ -44,6 +44,15 @@
vol.Inclusive(
CONF_LONGITUDE, "coordinates", "Latitude and longitude must exist together"
): cv.longitude,
vol.Optional(CONF_CHEAPEST_SENSORS, default=False): selector.BooleanSelector(),
vol.Optional(CONF_CHEAPEST_SENSORS_COUNT, default=5): selector.NumberSelector(
selector.NumberSelectorConfig(
mode=selector.NumberSelectorMode.SLIDER,
min=1,
max=10,
step=1
)
)
}
)

@@ -217,6 +226,8 @@ async def async_step_area_update(self, user_input: dict[str, Any] | None = None)
CONF_LATITUDE: user_input[CONF_LATITUDE],
CONF_LONGITUDE: user_input[CONF_LONGITUDE],
CONF_RADIUS: user_input[CONF_RADIUS],
CONF_CHEAPEST_SENSORS: user_input[CONF_CHEAPEST_SENSORS],
CONF_CHEAPEST_SENSORS_COUNT: user_input[CONF_CHEAPEST_SENSORS_COUNT]
}
)
return await self.async_step_area_menu()
@@ -250,6 +261,21 @@ async def async_step_area_update(self, user_input: dict[str, Any] | None = None)
"Latitude and longitude must exist together",
default=self.configuring_area[CONF_LONGITUDE],
): cv.longitude,
vol.Optional(
CONF_CHEAPEST_SENSORS,
default=self.configuring_area[CONF_CHEAPEST_SENSORS]
): selector.BooleanSelector(),
vol.Optional(
CONF_CHEAPEST_SENSORS_COUNT,
default=self.configuring_area[CONF_CHEAPEST_SENSORS_COUNT]
): selector.NumberSelector(
selector.NumberSelectorConfig(
mode=selector.NumberSelectorMode.SLIDER,
min=1,
max=10,
step=1
)
)
}
),
errors=errors,
@@ -435,6 +461,8 @@ async def async_step_area_create(self, user_input: dict[str, Any] | None = None)
CONF_LATITUDE: user_input[CONF_LATITUDE],
CONF_LONGITUDE: user_input[CONF_LONGITUDE],
CONF_RADIUS: user_input[CONF_RADIUS],
CONF_CHEAPEST_SENSORS: user_input[CONF_CHEAPEST_SENSORS],
CONF_CHEAPEST_SENSORS_COUNT: user_input[CONF_CHEAPEST_SENSORS_COUNT]
}
)
return await self.async_step_area_menu()
@@ -480,6 +508,8 @@ async def async_step_area_update(self, user_input: dict[str, Any] | None = None)
CONF_LATITUDE: user_input[CONF_LATITUDE],
CONF_LONGITUDE: user_input[CONF_LONGITUDE],
CONF_RADIUS: user_input[CONF_RADIUS],
CONF_CHEAPEST_SENSORS: user_input[CONF_CHEAPEST_SENSORS],
CONF_CHEAPEST_SENSORS_COUNT: user_input[CONF_CHEAPEST_SENSORS_COUNT]
}
)
return await self.async_step_area_menu()
@@ -513,6 +543,21 @@ async def async_step_area_update(self, user_input: dict[str, Any] | None = None)
"Latitude and longitude must exist together",
default=self.configuring_area[CONF_LONGITUDE],
): cv.longitude,
vol.Optional(
CONF_CHEAPEST_SENSORS,
default=self.configuring_area[CONF_CHEAPEST_SENSORS]
): selector.BooleanSelector(),
vol.Optional(
CONF_CHEAPEST_SENSORS_COUNT,
default=self.configuring_area[CONF_CHEAPEST_SENSORS_COUNT]
): selector.NumberSelector(
selector.NumberSelectorConfig(
mode=selector.NumberSelectorMode.SLIDER,
min=1,
max=10,
step=1
)
)
}
),
errors=errors,
16 changes: 12 additions & 4 deletions custom_components/fuel_prices/strings.json
Original file line number Diff line number Diff line change
@@ -33,7 +33,9 @@
"name": "Area name (must be unique)",
"radius": "Maximum search radius",
"latitude": "Latitude for the center of the search location",
"longitude": "Longitude for the center of the search location"
"longitude": "Longitude for the center of the search location",
"cheapest_stations": "Register entities for top n cheapest fuel stations in this area",
"cheapest_stations_count": "Number of cheapest fuel station entities to create"
}
},
"area_update_select": {
@@ -49,7 +51,9 @@
"name": "Area name (must be unique)",
"radius": "Maximum search radius",
"latitude": "Latitude for the center of the search location",
"longitude": "Longitude for the center of the search location"
"longitude": "Longitude for the center of the search location",
"cheapest_stations": "Register entities for top n cheapest fuel stations in this area",
"cheapest_stations_count": "Number of cheapest fuel station entities to create"
}
},
"area_delete": {
@@ -119,7 +123,9 @@
"name": "Area name (must be unique)",
"radius": "Maximum search radius",
"latitude": "Latitude for the center of the search location",
"longitude": "Longitude for the center of the search location"
"longitude": "Longitude for the center of the search location",
"cheapest_stations": "Register entities for top n cheapest fuel stations in this area",
"cheapest_stations_count": "Number of cheapest fuel station entities to create"
}
},
"area_update_select": {
@@ -135,7 +141,9 @@
"name": "Area name (must be unique)",
"radius": "Maximum search radius",
"latitude": "Latitude for the center of the search location",
"longitude": "Longitude for the center of the search location"
"longitude": "Longitude for the center of the search location",
"cheapest_stations": "Register entities for top n cheapest fuel stations in this area",
"cheapest_stations_count": "Number of cheapest fuel station entities to create"
}
},
"area_delete": {
16 changes: 12 additions & 4 deletions custom_components/fuel_prices/translations/en.json
Original file line number Diff line number Diff line change
@@ -33,7 +33,9 @@
"name": "Area name (must be unique)",
"radius": "Maximum search radius",
"latitude": "Latitude for the center of the search location",
"longitude": "Longitude for the center of the search location"
"longitude": "Longitude for the center of the search location",
"cheapest_stations": "Register entities for top n cheapest fuel stations in this area",
"cheapest_stations_count": "Number of cheapest fuel station entities to create"
}
},
"area_update_select": {
@@ -49,7 +51,9 @@
"name": "Area name (must be unique)",
"radius": "Maximum search radius",
"latitude": "Latitude for the center of the search location",
"longitude": "Longitude for the center of the search location"
"longitude": "Longitude for the center of the search location",
"cheapest_stations": "Register entities for top n cheapest fuel stations in this area",
"cheapest_stations_count": "Number of cheapest fuel station entities to create"
}
},
"area_delete": {
@@ -119,7 +123,9 @@
"name": "Area name (must be unique)",
"radius": "Maximum search radius",
"latitude": "Latitude for the center of the search location",
"longitude": "Longitude for the center of the search location"
"longitude": "Longitude for the center of the search location",
"cheapest_stations": "Register entities for top n cheapest fuel stations in this area",
"cheapest_stations_count": "Number of cheapest fuel station entities to create"
}
},
"area_update_select": {
@@ -135,7 +141,9 @@
"name": "Area name (must be unique)",
"radius": "Maximum search radius",
"latitude": "Latitude for the center of the search location",
"longitude": "Longitude for the center of the search location"
"longitude": "Longitude for the center of the search location",
"cheapest_stations": "Register entities for top n cheapest fuel stations in this area",
"cheapest_stations_count": "Number of cheapest fuel station entities to create"
}
},
"area_delete": {

0 comments on commit c6fcfae

Please sign in to comment.