"""
Support for HydroQuebec.

Get data from 'My Consumption Profile' page:
https://www.hydroquebec.com/portail/en/group/clientele/portrait-de-consommation

For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/sensor.hydroquebec/
"""
import asyncio
import logging
from datetime import timedelta

import voluptuous as vol

from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
    CONF_USERNAME, CONF_PASSWORD,
    CONF_NAME, CONF_MONITORED_VARIABLES, TEMP_CELSIUS)
from homeassistant.helpers.entity import Entity
from homeassistant.util import Throttle
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['pyhydroquebec==2.2.2']

_LOGGER = logging.getLogger(__name__)

KILOWATT_HOUR = 'kWh'  # type: str
PRICE = 'CAD'  # type: str
DAYS = 'days'  # type: str
CONF_CONTRACT = 'contract'  # type: str

DEFAULT_NAME = 'HydroQuebec'

REQUESTS_TIMEOUT = 15
MIN_TIME_BETWEEN_UPDATES = timedelta(hours=1)
SCAN_INTERVAL = timedelta(hours=1)

SENSOR_TYPES = {
    'balance':
    ['Balance', PRICE, 'mdi:square-inc-cash'],
    'period_total_bill':
    ['Period total bill', PRICE, 'mdi:square-inc-cash'],
    'period_length':
    ['Period length', DAYS, 'mdi:calendar-today'],
    'period_total_days':