diff --git a/homeassistant/components/fully_kiosk/services.py b/homeassistant/components/fully_kiosk/services.py index c1e0d89f7a1..b9369198940 100644 --- a/homeassistant/components/fully_kiosk/services.py +++ b/homeassistant/components/fully_kiosk/services.py @@ -69,18 +69,21 @@ async def async_setup_services(hass: HomeAssistant) -> None: async def async_set_config(call: ServiceCall) -> None: """Set a Fully Kiosk Browser config value on the device.""" for coordinator in await collect_coordinators(call.data[ATTR_DEVICE_ID]): + key = call.data[ATTR_KEY] + value = call.data[ATTR_VALUE] + # Fully API has different methods for setting string and bool values. # check if call.data[ATTR_VALUE] is a bool - if isinstance(call.data[ATTR_VALUE], bool) or call.data[ - ATTR_VALUE - ].lower() in ("true", "false"): - await coordinator.fully.setConfigurationBool( - call.data[ATTR_KEY], call.data[ATTR_VALUE] - ) + if isinstance(value, bool) or ( + isinstance(value, str) and value.lower() in ("true", "false") + ): + await coordinator.fully.setConfigurationBool(key, value) else: - await coordinator.fully.setConfigurationString( - call.data[ATTR_KEY], call.data[ATTR_VALUE] - ) + # Convert any int values to string + if isinstance(value, int): + value = str(value) + + await coordinator.fully.setConfigurationString(key, value) # Register all the above services service_mapping = [ @@ -111,7 +114,7 @@ async def async_setup_services(hass: HomeAssistant) -> None: { vol.Required(ATTR_DEVICE_ID): cv.ensure_list, vol.Required(ATTR_KEY): cv.string, - vol.Required(ATTR_VALUE): vol.Any(str, bool), + vol.Required(ATTR_VALUE): vol.Any(str, bool, int), } ) ), diff --git a/tests/components/fully_kiosk/test_services.py b/tests/components/fully_kiosk/test_services.py index 25c432166fa..6bce012aad3 100644 --- a/tests/components/fully_kiosk/test_services.py +++ b/tests/components/fully_kiosk/test_services.py @@ -71,6 +71,22 @@ async def test_services( mock_fully_kiosk.setConfigurationString.assert_called_once_with(key, value) + key = "test_key" + value = 1234 + + await hass.services.async_call( + DOMAIN, + SERVICE_SET_CONFIG, + { + ATTR_DEVICE_ID: [device_entry.id], + ATTR_KEY: key, + ATTR_VALUE: value, + }, + blocking=True, + ) + + mock_fully_kiosk.setConfigurationString.assert_called_with(key, str(value)) + key = "test_key" value = "true" await hass.services.async_call(