8000 Add forecast service to amberelectric by madpilot · Pull Request #144848 · home-assistant/core · GitHub
[go: up one dir, main page]

Skip to content

Add forecast service to amberelectric #144848

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 55 commits into from
Jul 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3c9994e
Add price descriptor attribute to price sensors
madpilot Mar 11, 2022
1a720e9
Adding price descriptor sensor
madpilot Mar 11, 2022
4b48e17
Use correct number of sensors in spike sensor tests
madpilot Mar 11, 2022
f6731a2
Merge pull request #28 from madpilot/amber-price-descriptors
madpilot Mar 11, 2022
14ac1c9
Merge branch 'home-assistant:dev' into dev
madpilot Mar 14, 2022
70a5f7f
Add tests for normalize_descriptor
madpilot Mar 14, 2022
3079e6c
Removing debug message
madpilot Mar 14, 2022
433e4e0
Merge branch 'home-assistant:dev' into dev
madpilot Mar 14, 2022
8605e2d
Removing price_descriptor attribute from the current sensor
madpilot Mar 14, 2022
3e04ba0
Merge remote-tracking branch 'upstream/dev' into dev
madpilot Apr 12, 2022
ba8025e
Merge remote-tracking branch 'upstream/dev' into dev
madpilot Jul 14, 2023
d5d930d
Merge remote-tracking branch 'upstream/dev' into dev
madpilot Nov 30, 2023
1d6eed0
Merge remote-tracking branch 'upstream/dev' into dev
madpilot Jan 11, 2024
954220c
Merge remote-tracking branch 'upstream/dev' into dev
madpilot Jul 2, 2024
b282aaa
Merge remote-tracking branch 'upstream/dev' into dev
madpilot Jul 3, 2024
1a0b281
Merge remote-tracking branch 'upstream/dev' into dev
madpilot Jul 6, 2024
42c449f
Merge remote-tracking branch 'upstream/dev' into dev
madpilot Nov 30, 2024
24f4d18
Merge remote-tracking branch 'upstream/dev' into dev
madpilot Mar 20, 2025
bc08ebe
Merge remote-tracking branch 'upstream/dev' into dev
madpilot May 29, 2025
fe6c66d
POC
madpilot May 13, 2025
0c42002
Adding strings and tests
madpilot May 15, 2025
565b5e2
Fix circular dependency
madpilot May 15, 2025
6b152fe
Moving fixtures to conftest.py
madpilot May 16, 2025
57dd632
Creating issue if someone is using a forecast in an automation or script
madpilot May 16, 2025
737de42
Adding deprecation warning if forecasts are used in scripts or automa…
madpilot May 16, 2025
9813276
Moving single use files back to sensor.py, rename formatters to helpers
madpilot May 20, 2025
5fb9e1b
Renaming test_formatters to test_helpers
madpilot May 20, 2025
fa7979f
Removing deprecation warning - will add back in to the next PR
madpilot May 20, 2025
91c2237
Adding a schema to the get forecast service
madpilot May 20, 2025
da2ceae
Reording json string keys
madpilot May 20, 2025
b8ee781
Fixing type on
madpilot May 20, 2025
058a67d
Moving format_cents_to_dollars to helpers.py
madpilot May 26, 2025
4b74c42
Updating get_forecasts type
madpilot May 26, 2025
77e6fd7
Test refactor WIP
madpilot May 29, 2025
ed6d654
Fix sensor tests
madpilot May 29, 2025
dbcbf63
Fixing service tests
madpilot May 29, 2025
f73c98a
Fix strings as per feedback
madpilot May 29, 2025
2aa55dc
Updating translation sting for api_token
madpilot Jun 4, 2025
47b0fae
Sentence case site name
madpilot Jun 6, 2025
e4c6202
Rename descriptor_map => DESCRIPTOR_MAP
madpilot Jun 22, 2025
51120a5
Add test for ServiceValidationError when the requested channel doesn'…
madpilot Jun 22, 2025
71f4916
Using config_entity_id instead of site_id
madpilot Jul 5, 2025
3dd76c0
Using str in the schema
madpilot Jul 5, 2025
2452b56
Update services.py
madpilot Jul 7, 2025
b8a5e27
Update services.py
madpilot Jul 7, 2025
4e8d808
Update conftest.py
madpilot Jul 7, 2025
852ba8a
Update conftest.py
madpilot Jul 7, 2025
0bbe4d3
Fixing tests
madpilot Jul 7, 2025
fa0b0a8
Use the word integration, not entity
madpilot Jul 8, 2025
d766760
Using constants for schema
madpilot Jul 8, 2025
aa484ad
Replace 'for your proerty' with 'for a site'
madpilot Jul 8, 2025
cc1d36e
Use correct name for config entry
madpilot Jul 8, 2025
01170dd
Fix typo
madpilot Jul 8, 2025
18beee8
8000 Removing config entry from service validation error
madpilot Jul 8, 2025
9c381a7
Using the config entry id in the service validation error
madpilot Jul 8, 2025
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
Next Next commit
Add price descriptor attribute to price sensors
  • Loading branch information
madpilot committed Mar 11, 2022
commit 3c9994eca56dbaab61415c5dbadfaebddfaa13c7
2 changes: 1 addition & 1 deletion homeassistant/components/amberelectric/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"@madpilot"
],
"requirements": [
"amberelectric==1.0.3"
"amberelectric==1.0.4"
],
"iot_class": "cloud_polling",
"loggers": ["amberelectric"]
Expand Down
2 changes: 2 additions & 0 deletions homeassistant/components/amberelectric/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None:
data["renewables"] = round(interval.renewables)
data["estimate"] = interval.estimate
data["spike_status"] = interval.spike_status.value
data["descriptor"] = interval.descriptor.value
data["channel_type"] = interval.channel_type.value

if interval.range is not None:
Expand Down Expand Up @@ -160,6 +161,7 @@ def extra_state_attributes(self) -> Mapping[str, Any] | None:
datum["end_time"] = interval.end_time.isoformat()
datum["renewables"] = round(interval.renewables)
datum["spike_status"] = interval.spike_status.value
datum["descriptor"] = interval.descriptor.value

if interval.range is not None:
datum["range_min"] = format_cents_to_dollars(interval.range.min)
Expand Down
5 changes: 4 additions & 1 deletion tests/components/amberelectric/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from amberelectric.model.channel import ChannelType
from amberelectric.model.current_interval import CurrentInterval
from amberelectric.model.forecast_interval import ForecastInterval
from amberelectric.model.interval import SpikeStatus
from amberelectric.model.interval import Descriptor, SpikeStatus
from dateutil import parser


Expand All @@ -26,6 +26,7 @@ def generate_actual_interval(
renewables=50,
channel_type=channel_type.value,
spike_status=SpikeStatus.NO_SPIKE.value,
descriptor=Descriptor.LOW.value,
)


Expand All @@ -45,6 +46,7 @@ def generate_current_interval(
renewables=50.6,
channel_type=channel_type.value,
spike_status=SpikeStatus.NO_SPIKE.value,
descriptor=Descriptor.LOW.value,
estimate=True,
)

Expand All @@ -65,6 +67,7 @@ def generate_forecast_interval(
renewables=50,
channel_type=channel_type.value,
spike_status=SpikeStatus.NO_SPIKE.value,
descriptor=Descriptor.LOW.value,
estimate=True,
)

Expand Down
6 changes: 6 additions & 0 deletions tests/components/amberelectric/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ async def test_general_price_sensor(hass: HomeAssistant, setup_general: Mock) ->
assert attributes["renewables"] == 51
assert attributes["estimate"] is True
assert attributes["spike_status"] == "none"
assert attributes["descriptor"] == "low"
assert attributes["channel_type"] == "general"
assert attributes["attribution"] == "Data provided by Amber Electric"
assert attributes.get("range_min") is None
Expand Down Expand Up @@ -155,6 +156,7 @@ async def test_general_and_controlled_load_price_sensor(
assert attributes["renewables"] == 51
assert attributes["estimate"] is True
assert attributes["spike_status"] == "none"
assert attributes["descriptor"] == "low"
assert attributes["channel_type"] == "controlledLoad"
assert attributes["attribution"] == "Data provided by Amber Electric"

Expand All @@ -178,6 +180,7 @@ async def test_general_and_feed_in_price_sensor(
assert attributes["renewables"] == 51
assert attributes["estimate"] is True
assert attributes["spike_status"] == "none"
assert attributes["descriptor"] == "low"
assert attributes["channel_type"] == "feedIn"
assert attributes["attribution"] == "Data provided by Amber Electric"

Expand All @@ -204,6 +207,7 @@ async def test_general_forecast_sensor(
assert first_forecast["end_time"] == "2021-09-21T09:00:00+10:00"
assert first_forecast["renewables"] == 50
assert first_forecast["spike_status"] == "none"
assert first_forecast["descriptor"] == "low"

assert first_forecast.get("range_min") is None
assert first_forecast.get("range_max") is None
Expand Down Expand Up @@ -246,6 +250,7 @@ async def test_controlled_load_forecast_sensor(
assert first_forecast["end_time"] == "2021-09-21T09:00:00+10:00"
assert first_forecast["renewables"] == 50
assert first_forecast["spike_status"] == "none"
assert first_forecast["descriptor"] == "low"


async def test_feed_in_forecast_sensor(
Expand All @@ -270,6 +275,7 @@ async def test_feed_in_forecast_sensor(
assert first_forecast["end_time"] == "2021-09-21T09:00:00+10:00"
assert first_forecast["renewables"] == 50
assert first_forecast["spike_status"] == "none"
assert first_forecast["descriptor"] == "low"


def test_renewable_sensor(hass: HomeAssistant, setup_general) -> None:
Expand Down
0