Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Flix6x committed Mar 26, 2024
2 parents ec10413 + 1459362 commit 5fd3d41
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion homeassistant/components/flexmeasures/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"dependencies": ["http"],
"documentation": "https://www.home-assistant.io/integrations/flexmeasures",
"iot_class": "cloud_polling",
"requirements": ["flexmeasures-client==0.1.9", "isodate==0.6.1"]
"requirements": ["flexmeasures-client==0.1.10", "isodate==0.6.1"]
}
6 changes: 3 additions & 3 deletions homeassistant/components/flexmeasures/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfEnergy
from homeassistant.const import UnitOfPower
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback
Expand All @@ -28,8 +28,8 @@ async def async_setup_entry(
class FlexMeasuresScheduleSensor(SensorEntity):
"""Sensor to store the schedule created by FlexMeasures."""

_attr_device_class = SensorDeviceClass.ENERGY
_attr_native_unit_of_measurement = UnitOfEnergy.MEGA_WATT_HOUR
_attr_device_class = SensorDeviceClass.POWER
_attr_native_unit_of_measurement = UnitOfPower.KILO_WATT

def __init__(self) -> None:
"""Sensor to store the schedule created by FlexMeasures."""
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/flexmeasures/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import voluptuous as vol

from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfPower
from homeassistant.core import HomeAssistant, ServiceCall
from homeassistant.helpers.dispatcher import async_dispatcher_send
import homeassistant.util.dt as dt_util
Expand Down Expand Up @@ -114,6 +115,11 @@ async def trigger_and_get_schedule(
LOGGER.info(schedule_input)
schedule = await client.trigger_and_get_schedule(**schedule_input)

schedule["values"] = client.convert_units(
schedule["values"],
from_unit=schedule["unit"],
to_unit=UnitOfPower.KILO_WATT,
)
schedule = [
{"start": start + resolution * i, "value": value}
for i, value in enumerate(schedule["values"])
Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,7 @@ fjaraskupan==2.2.0
flexit_bacnet==2.1.0

# homeassistant.components.flexmeasures
flexmeasures-client==0.1.9
flexmeasures-client==0.1.10

# homeassistant.components.flipr
flipr-api==1.5.1
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ fjaraskupan==2.2.0
flexit_bacnet==2.1.0

# homeassistant.components.flexmeasures
flexmeasures-client==0.1.9
flexmeasures-client==0.1.10

# homeassistant.components.flipr
flipr-api==1.5.1
Expand Down
4 changes: 2 additions & 2 deletions tests/components/flexmeasures/test_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def test_trigger_and_get_schedule(
"""Test that the method trigger_and_get_schedule is awaited when calling the service trigger_and_get_schedule."""
with patch(
"flexmeasures_client.client.FlexMeasuresClient.trigger_and_get_schedule",
return_value={"values": [0.5, 0.41492, -0.0, -0.0]},
return_value={"values": [0.5, 0.41492, -0.0, -0.0], "unit": "MW"},
) as mocked_FlexmeasuresClient:
await hass.services.async_call(
DOMAIN,
Expand All @@ -59,7 +59,7 @@ async def test_trigger_and_get_schedule(


async def test_post_measurements(hass: HomeAssistant, setup_fm_integration) -> None:
"""Test that the method post measuresments is called when calling the service post_measurements."""
"""Test that the method post measurements is called when calling the service post_measurements."""

with patch(
"flexmeasures_client.client.FlexMeasuresClient.post_measurements",
Expand Down

0 comments on commit 5fd3d41

Please sign in to comment.