1
mirror of https://github.com/home-assistant/core synced 2024-10-07 10:13:38 +02:00
ha-core/tests/fixtures
Eugenio Panadero 8d2e72cdf6
Add pvpc electricity prices integration (#32092)
* Add new integration: pvpc_hourly_pricing

to add a sensor with the current hourly price of electricity in Spain.
Configuration is done by selecting one of the 3 reference tariffs, with
1, 2, or 3 billing periods.

* Features config flow, entity registry, RestoreEntity, options flow
  to change tariff, manual yaml config as integration or sensor platform
* Cloud polling sensor with minimal API calls (3/hour at random times)
  and smart retry; fully async
* Only 1 state change / hour (only when the price changes)
* At evening, try to download published tomorrow prices, to always store
  prices info for a window of [3, 27] hours in the future.
* Include useful state attributes to program automations to be run
  at best electric prices.
* Add spanish and english translations.

* Requires `xmltodict` to parse official xml file with hourly prices
for each day.

* Update requirements and add to codeowners

* Avoid passing in hass as a parameter to the entity

Instead, create time change listeners in async_added_to_hass and
call async_generate_entity_id before async_add_entities

* Fix lint issues

* Add tests for config & options flow

* Add tests for manual yaml config

with entity definition as integration and also as a sensor platform

* Fix placement of PLATFORM_SCHEMA and update generated config_flows

* Store prices internally linked to UTC timestamps

- to deal with days with DST changes
- and work with different local timezones

* Add availability to sensor

to 'expire' the sensor if there is no connection available
 and current hour is not in the stored prices.

Also, turn off logging and retrying if prices can't be downloaded
repeatedly, by flagging `data_source_available` as False, so there is no
log-flood mess.

* Add more tests

- to cover behavior in DST changes and complete coverage of sensor logic
- to cover abort config flow

* fix linter

* Better handling of sensor availability and minor enhancements

- Emmit 1 error if data source is marked as unavailable
  (after some retries), and be silent until cloud access is recovered,
  then emmit 1 warning.
- Follow standard of camel_case keys in attributes

* Mock aiosession to not access real API, store fixture data

- Store a set of daily xml files to test sensor logic for all situations
- Mock time and session to run tests with stored API responses
- Add availability test to simulate a lost + recovery of cloud access,
  checking that logging is reasonable: 1 error to flag the continued
  disconnection + 1 warning in recovery.

* Change API endpoint to retrieve JSON data

and remove xmltodict from reqs.

It seems that this endpoint is more reliable than the XML.

* Adapt tests to new API endpoint

* Translate tariff labels to plain English

and sync the default timeout value for all ways of configuration.

* Relax logging levels to meet silver requirements

- 1 warning when becoming unavailable, another warning when recovered.
- Warnings for unexpected TimeoutError or ClientError
- Move the rest to debug level, leaving info for HA internals

Also reduce number of API calls from 3 to 2 calls/hour.

* Fix requirements

* Mod tests to work with timezone Atlantic/Canary

and fix state attributes for timezones != reference, by using 3 price
prefixes: 'price_last_day_XXh', 'price_next_day_XXh' and 'price_XXh',
all generated with local time (backend timezone)

* Try to fix CI tests

* Externalize pvpc data and simplify sensor.py

* add new `aiopvpc` to requirements
* Remove data parsing and price logic from here
* Replace some constant properties with class variables

* Simplify tests for pvpc_hourly_pricing

* Fix updater for options flow

* Updater always reloads
* `tariff` value comes 1st from entry.options, 2nd from entry.data

* Fix lint

* Bump aiopvpc

* Remove options flow and platform setup

- Remove PLATFORM_SCHEMA and async_setup_platform
- Generate config_entry.unique_id with tariff instead of entity_id, in flow step.
- Remove TariffSelectorConfigFlow
- Adapt tests to maintain full coverage

* Fix docstring on test

and rename SENSOR_SCHEMA to SINGLE_SENSOR_SCHEMA to avoid confusion

* Remove timeout manual config, fix entry.options usage, simplify unique_id

* Simplify tests

- No need for a test_setup now, as platform setup is removed and integration
  setup is already used in `test_availability`
- Simplified `_process_time_step`: only one async_fire(EVENT_TIME_CHANGED)/hour

* Fix possible duplicated update

when source is not available.

* Do not access State last_changed for log messages

* Do not update until entity is added to hass

and call to async_update after 1st download or when recovering access, so
async_write_ha_state is not called twice on those.

* minor changes

* Rename method to select current price and make it a callback
2020-03-22 14:25:31 -05:00
..
august Lock operation sensors for August (#32593) 2020-03-10 17:09:49 -07:00
elgato Add Elgato Key Light integration (#29592) 2019-12-08 09:26:31 +01:00
griddy Add griddy integration (#32591) 2020-03-10 23:00:30 +01:00
here_travel_time Add here_travel_time (#24603) 2019-09-23 11:50:18 +02:00
homekit_controller Add support for homekit valve accessories to homekit_controller (#32937) 2020-03-18 21:20:40 +00:00
nexia Add support for nexia automations (#33049) 2020-03-20 18:49:42 -05:00
powerwall Add Powerwalls integration (#32851) 2020-03-19 10:50:17 -05:00
pvpc_hourly_pricing Add pvpc electricity prices integration (#32092) 2020-03-22 14:25:31 -05:00
wled Add Wi-Fi sensors to WLED integration (#33055) 2020-03-21 15:14:41 -07:00
abode_automation_changed.json Add Abode tests (#32562) 2020-03-16 03:05:10 +01:00
abode_automation.json Add Abode tests (#32562) 2020-03-16 03:05:10 +01:00
abode_devices.json Add Abode tests (#32562) 2020-03-16 03:05:10 +01:00
abode_login.json Add Abode tests (#32562) 2020-03-16 03:05:10 +01:00
abode_oauth_claims.json Add Abode tests (#32562) 2020-03-16 03:05:10 +01:00
abode_panel.json Add Abode tests (#32562) 2020-03-16 03:05:10 +01:00
airly_no_station.json Add Airly integration (#26375) 2019-10-04 13:58:29 +02:00
airly_valid_station.json Add Airly integration (#26375) 2019-10-04 13:58:29 +02:00
alpr_cloud.json
alpr_stdout.txt
ambient_devices.json
aurora.txt Fix aurora sensor not converting latitude and longitude correctly (#28643) 2020-01-09 08:40:10 +01:00
awair_air_data_latest_updated.json
awair_air_data_latest.json
awair_devices.json
bom_weather.json
brother_printer_data.json Tests improvements to the Brother integration (#32982) 2020-03-20 10:21:43 +01:00
coinmarketcap.json
darksky.json
Ddwrt_Status_Lan.txt
Ddwrt_Status_Wireless.txt
efergy_budget.json
efergy_cost.json
efergy_current_values_multi.json
efergy_current_values_single.json
efergy_energy.json
efergy_instant.json
feedreader1.xml
feedreader2.xml
feedreader3.xml
feedreader4.xml fix feedreader handling unrecognized published date (#28225) 2019-10-31 21:05:42 +01:00
feedreader.xml
foobot_data.json
foobot_devices.json
google_maps_elevation.json
homematicip_cloud.json Add new devices to HomematicIP Cloud (#31914) 2020-02-19 10:43:12 +01:00
ip-api.com.json
ipapi.co.json
london_air.json
melissa_cur_settings.json
melissa_fetch_devices.json
melissa_status.json
microsoft_face_create_person.json
microsoft_face_detect.json
microsoft_face_identify.json
microsoft_face_persongroups.json
microsoft_face_persons.json
openhardwaremonitor.json
pushbullet_devices.json
ring_chime_health_attrs.json
ring_devices_updated.json Update Ring to 0.6.0 (#30748) 2020-01-14 12:54:45 -08:00
ring_devices.json Update Ring to 0.6.0 (#30748) 2020-01-14 12:54:45 -08:00
ring_ding_active.json
ring_doorboot_health_attrs.json
ring_doorbot_siren_on_response.json
ring_doorbots.json
ring_oauth.json Fixes invalid JSON files and whitespace corrections in YAML files (#26396) 2019-09-03 16:02:42 -07:00
ring_session.json
sleepiq-bed-single.json
sleepiq-bed.json
sleepiq-familystatus-single.json
sleepiq-familystatus.json
sleepiq-login-failed.json
sleepiq-login.json
sleepiq-sleeper.json
smhi.json
uk_transport_bus.json
uk_transport_train.json
unifi_direct.txt
upc_connect.xml
vultr_account_info.json
vultr_server_list.json
wsdot.json
wunderground-error.json
wunderground-invalid.json
wunderground-valid.json
yahoo_finance.json
yahooweather.json
yandex_transport_reply.json Fix Yandex transport after API change (#32500) 2020-03-07 18:26:35 +01:00
yr.no.xml Fix incorrect file format yr test fixure (#29910) 2019-12-13 12:29:24 +01:00