Code Monkey home page Code Monkey logo

pyhydroquebec's Introduction

PyHydroQuebec

DEPRECATED - please used https://gitlab.com/hydroqc/hydroqc

TODO

  • Add automated tests

Installation

pip install pyhydroquebec

Usage

Print your current data

pyhydroquebec -u MYACCOUNT -p MYPASSWORD

List your current contracts

:: config.yaml PYHQ_OUTPUT=MQTT registry.gitlab.com/ttblt-hass/pyhydroquebec:master

pyhydroquebec -u MYACCOUNT -p MYPASSWORD -l

Print help

usage: pyhydroquebec [-h] [-u USERNAME] [-p PASSWORD] [-j] [-i] [-c CONTRACT]
                    [-l] [-H] [-t TIMEOUT] [-V] [--detailled-energy]
                    [--start-date START_DATE] [--end-date END_DATE]

optional arguments:
    -h, --help                          show this help message and exit
    -u USERNAME, --username USERNAME    Hydro Quebec username
    -p PASSWORD, --password PASSWORD    Password
    -j, --json                          Json output
    -i, --influxdb                      InfluxDb output
    -c CONTRACT, --contract CONTRACT    Contract number
    -l, --list-contracts                List all your contracts
    -H, --hourly                        Show yesterday hourly consumption
    -t TIMEOUT, --timeout TIMEOUT       Request timeout
    -V, --version                       Show version

Detailled-energy raw download option:
    --detailled-energy                  Get raw json output download
    --start-date START_DATE             Start date for detailled-output
    --end-date END_DATE                 End date for detailled-output

MQTT DAEMON

cp config.yaml.sample config.yaml

Note: If 'frequency' is not set the "daemon" will collect the data only one time and stop

Edit config.yaml

MQTT_USERNAME=mqtt_username MQTT_PASSWORD=mqtt_password MQTT_HOST=mqtt_ip MQTT_PORT=mqtt_port CONFIG=config.yaml mqtt_pyhydroquebec

With Docker

MQTT_USERNAME=mqtt_username MQTT_PASSWORD=mqtt_password MQTT_HOST=mqtt_ip MQTT_PORT=mqtt_port CONFIG=config.yaml PYHQ_OUTPUT=MQTT registry.gitlab.com/ttblt-hass/pyhydroquebec:master

Docker

Docker image list: https://gitlab.com/ttblt-hass/pyhydroquebec/container_registry

docker run -e PYHQ_USER=*** -e PYHQ_PASSWORD=*** registry.gitlab.com/ttblt-hass/pyhydroquebec:master

Docker variables

PYHQ_USER - Required
-e PYHQ_USER=myusername
PYHQ_PASSWORD - Required
-e PYHQ_PASSWORD=mypassword

PYHQ_OUTPUT

  • -e PYHQ_OUTPUT=TEXT - Default
  • -e PYHQ_OUTPUT=JSON
  • -e PYHQ_OUTPUT=INFLUXDB
  • -e PYHQ_OUTPUT=CONTRACT

PYHQ_CONTRACT

-e PYHQ_CONTRACT=332211223

Dev env

make env

Run test

USERNAME=myhydrousername PASSWORD=myhydropassword tox

pyhydroquebec's People

Contributors

balloob avatar chdagenais avatar diogos88 avatar embak avatar jeremiecharest avatar kevmegforest avatar llluis avatar mrnvzch avatar ncareau avatar syedair avatar titilambert avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyhydroquebec's Issues

PyYAML installation failure

Describe the bug
Installation of pyhydroquebec fails on PyYAML dependency

To Reproduce
Steps to reproduce the behavior:
pip install pyhydroquebec

  Attempting uninstall: PyYAML
    Found existing installation: PyYAML 5.3
ERROR: Cannot uninstall 'PyYAML'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

Expected behavior
Have PyYAML correcting installed

PyHydroQuebec and Python version
Please write here which version of Python and PyHydroQuebec you are using.
Python 3.7.6
git clone. Last version of PyHydroQuebec

Threads seem to multiply with each execution

Describe the bug

I've been getting crashes for a while. In the pyhydroquebec logs, the log entries seem to be copied 2, then 3, then 4 times and so one until the docker image crashes and restarts.

To Reproduce

I run pyhydroquebec in docker as described here.

#49 (comment)

Expected behavior
Shouldn't crash repeatedly :)

This is what I get in my logs.

2021-02-20 20:50:49,640 - INFO - mqtt-hydroquebec - Initializing...
2021-02-20 20:50:49,642 - INFO - mqtt-hydroquebec - Start main process
2021-02-20 20:50:49,642 - INFO - mqtt-hydroquebec - Connecting to MQTT server
2021-02-20 20:50:49,642 - INFO - mqtt-hydroquebec - Reaching MQTT server
2021-02-20 20:50:49,643 - INFO - pyhydroquebec - Log in using [email protected]
2021-02-20 20:50:52,569 - INFO - pyhydroquebec - fetching customers
2021-02-20 20:50:52,725 - INFO - pyhydroquebec.customer.0123456789 - Fetching summary page
2021-02-20 20:50:52,725 - INFO - pyhydroquebec - Selecting customer 0123456789
2021-02-20 20:50:59,687 - INFO - pyhydroquebec - Customer 0123456789 selected
2021-02-20 20:51:05,174 - INFO - pyhydroquebec.customer.0123456789 - Fetching current period data
2021-02-20 20:51:09,500 - INFO - pyhydroquebec.customer.0123456789 - Fetching daily data between 2021-02-19 and 2021-02-19
2021-02-20 20:51:09,561 - INFO - mqtt-hydroquebec - Waiting for 10800 seconds before the next check
2021-02-20 23:51:26,086 - INFO - pyhydroquebec - Log in using [email protected]
2021-02-20 23:51:26,086 - INFO - pyhydroquebec - Log in using [email protected]
2021-02-20 23:51:28,234 - INFO - pyhydroquebec - fetching customers
2021-02-20 23:51:28,234 - INFO - pyhydroquebec - fetching customers
2021-02-20 23:51:29,318 - INFO - pyhydroquebec.customer.0123456789 - Fetching summary page
2021-02-20 23:51:29,318 - INFO - pyhydroquebec.customer.0123456789 - Fetching summary page
2021-02-20 23:51:29,318 - INFO - pyhydroquebec - Selecting customer 0123456789
2021-02-20 23:51:29,318 - INFO - pyhydroquebec - Selecting customer 0123456789
2021-02-20 23:51:42,850 - INFO - pyhydroquebec - Customer 0123456789 selected
2021-02-20 23:51:42,850 - INFO - pyhydroquebec - Customer 0123456789 selected
2021-02-20 23:51:51,807 - INFO - pyhydroquebec.customer.0123456789 - Fetching current period data
2021-02-20 23:51:51,807 - INFO - pyhydroquebec.customer.0123456789 - Fetching current period data
2021-02-20 23:51:57,261 - INFO - pyhydroquebec.customer.0123456789 - Fetching daily data between 2021-02-19 and 2021-02-19
2021-02-20 23:51:57,261 - INFO - pyhydroquebec.customer.0123456789 - Fetching daily data between 2021-02-19 and 2021-02-19
2021-02-20 23:51:57,309 - INFO - mqtt-hydroquebec - Waiting for 10800 seconds before the next check
2021-02-21 02:52:14,064 - INFO - pyhydroquebec - Log in using [email protected]
2021-02-21 02:52:14,064 - INFO - pyhydroquebec - Log in using [email protected]
2021-02-21 02:52:14,064 - INFO - pyhydroquebec - Log in using [email protected]
2021-02-21 02:52:16,599 - INFO - pyhydroquebec - fetching customers
2021-02-21 02:52:16,599 - INFO - pyhydroquebec - fetching customers
2021-02-21 02:52:16,599 - INFO - pyhydroquebec - fetching customers
2021-02-21 02:52:16,768 - INFO - pyhydroquebec.customer.0123456789 - Fetching summary page
2021-02-21 02:52:16,768 - INFO - pyhydroquebec.customer.0123456789 - Fetching summary page
2021-02-21 02:52:16,768 - INFO - pyhydroquebec.customer.0123456789 - Fetching summary page
2021-02-21 02:52:16,769 - INFO - pyhydroquebec - Selecting customer 0123456789
2021-02-21 02:52:16,769 - INFO - pyhydroquebec - Selecting customer 0123456789
2021-02-21 02:52:16,769 - INFO - pyhydroquebec - Selecting customer 0123456789
2021-02-21 02:52:25,660 - INFO - pyhydroquebec - Customer 0123456789 selected
2021-02-21 02:52:25,660 - INFO - pyhydroquebec - Customer 0123456789 selected
2021-02-21 02:52:25,660 - INFO - pyhydroquebec - Customer 0123456789 selected
2021-02-21 02:52:31,857 - INFO - pyhydroquebec.customer.0123456789 - Fetching current period data
2021-02-21 02:52:31,857 - INFO - pyhydroquebec.customer.0123456789 - Fetching current period data
2021-02-21 02:52:31,857 - INFO - pyhydroquebec.customer.0123456789 - Fetching current period data
2021-02-21 02:52:36,380 - INFO - pyhydroquebec.customer.0123456789 - Fetching daily data between 2021-02-19 and 2021-02-19
2021-02-21 02:52:36,380 - INFO - pyhydroquebec.customer.0123456789 - Fetching daily data between 2021-02-19 and 2021-02-19
2021-02-21 02:52:36,380 - INFO - pyhydroquebec.customer.0123456789 - Fetching daily data between 2021-02-19 and 2021-02-19
2021-02-21 02:52:36,436 - INFO - mqtt-hydroquebec - Waiting for 10800 seconds before the next check

PyHydroQuebec and Python version
Latest docker images.

registry.gitlab.com/ttblt-hass/pyhydroquebec/mqtt   master    be277f330a52   16 months ago   115MB

Hydroquebec rate

Select your rate:

  • D
  • DP
  • DM
  • DT

Hydroquebec multi-contract
Do you have more than one contract with HydroQuebec ?

  • Yes
  • [x ] No

Corner Cases
Are you in one of this situations:

  • Change of address
  • Change of rate
  • Add a new contract
  • Remove an old contract
  • [ x ] No
  • Other:

Additional context

Login Expires when listing clients

I have more than 60 clients with more than 100 contracts linked to my HQ username. Listing the clients in the login page take more than 15 minutes so the client fails after the 899 seconds expiry set in the callback url :

'https://session.hydroquebec.com/oauth2/callback#access_token=eyJ0eXAiOiJKV1QiLCJ6aXAiOiJOT05FIiwia2lkIjoib1JudHVEUVFaSlV4SitXaHVNR1UwVVhaUlFZPSIsImFsZyI6IlJTMjU2In0.eyJzdWIiOiJBQUhTNzgwNjIiLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXV0aF9sZXZlbCI6MCwiYXVkaXRUcmFja2luZ0lkIjoiMmEwOTBkNDUtNjYwNC00MzI5LWI4M2YtYjY3MTZjOGIzZmQ0LTIwNTU2Nzg1NCIsImlzcyI6Imh0dHBzOi8vY29ubmV4aW9uLmh5ZHJvcXVlYmVjLmNvbTo0NDMvaHFhbS9vYXV0aDIiLCJ0b2tlbk5hbWUiOiJhY2Nlc3NfdG9rZW4iLCJ0b2tlbl90eXBlIjoiQmVhcmVyIiwiYXV0aEdyYW50SWQiOiJGVG5mMmNZdVNfbi1uT21WMHZwSnFuQzZrQTgiLCJub25jZSI6IkxRcFFNcmZqNGd0SkhUd2xnZFRCWE1UN0ZzaHQ1SnNNdnQzSlYxU08iLCJhdWQiOiJNRl9JMzM0NjhmNTYtZWZmNy00YWQ4LTkzNjMtY2RjNzM3YmI0MDViIiwibmJmIjoxNTgyMjIyNTE3LCJncmFudF90eXBlIjoidG9rZW4iLCJzY29wZSI6WyJvcGVuaWQiLCJwcm9maWxlIiwiZW1haWwiXSwiYXV0aF90aW1lIjoxNTgyMjIyNTE3LCJyZWFsbSI6Ii9jbGllbnRzIiwiZXhwIjoxNTgyMjIzNDE3LCJpYXQiOjE1ODIyMjI1MTcsImV4cGlyZXNfaW4iOjkwMCwianRpIjoiSDNxenUzUmZxVmVHdmRlQVE1RHVseVlaeTVBIn0.FiVwhCmwVNdx3hZulXRQbbaEI6Im3tcf5XlrMYLGzoVIxdxJAhuce2505XTVi-UOoFdswai4NovnRYjkJpnCnfYE_8faLt0B15N90g60BSA2uK6P4Dnb7ettDI-3eS2HPwWJX_k-6HZSOQqGKV0xmXg7K-K7lPog_ZO9EExxWkpwT0xZvmgUhy10GDzHLYXscXN7CzG04qrhsC-eP7tZkhNG40xewZcZ2m2D8NuKk14ixTRuJ4ivYUHsuK4s9H3dUpq1rsSQG5HBchoOFfphpqnoMHr2QQ3ocDPZ3IMVbNF2z5Q6eoX084CJVLQ-AOguKqhz7BMqRBX4yesOqx2HlHdh-fqlUKgg3cyjbVCFjGJO6NXNqhrcKv1K5UeOzvguYrfLbLppFPecDwGSM3cVoFdqOnDEwWkIFtyaUg46JrIltPZ9IMn3VoWZ6WDiBPB61eF_i8wtuWG7i4A6orbaCtXacYY5fq410VsENN_-rAqyVRHSvm7u5qglkbwFKbI-QBdXJa-mQ0KydYHe3YsQl0eLZSr1UenVQoADeTnEm1UHLfGfkPCa1Qn8zH6WiHhOYKC8OrFbdz-8eP31zryLlVs-q9tkJcbW4QZ1OQNqv3-3PyAWkv42X0Dev0dCSMDdR0Qz7vps0dH97Gz6w0JgV7ge6l-H1aaRB-cjG9sdeB4&id_token=eyJ0eXAiOiJKV1QiLCJraWQiOiJvUm50dURRUVpKVXhKK1dodU1HVTBVWFpSUVk9IiwiYWxnIjoiUlMyNTYifQ.eyJhdF9oYXNoIjoiNncwT1lmNEFCSjlBX09IT0hfclY1QSIsInN1YiI6IkFBSFM3ODA2MiIsImRpc3BsYXlOYW1lIjoiRGVzbWFyYWlzLCBCZW5qYW1pbiIsImF1ZGl0VHJhY2tpbmdJZCI6IjJhMDkwZDQ1LTY2MDQtNDMyOS1iODNmLWI2NzE2YzhiM2ZkNC0yMDU1Njc4NTgiLCJyb2xlcyI6WyJST0xFX0FQUEwtT0ktUFJPRC1DTElFTlQiLCJST0xFX0FQUEwtQ0wtUFJPRC1JTlRFUk5BVVRFUy1FQyJdLCJpc3MiOiJodHRwczovL2Nvbm5leGlvbi5oeWRyb3F1ZWJlYy5jb206NDQzL2hxYW0vb2F1dGgyIiwidG9rZW5OYW1lIjoiaWRfdG9rZW4iLCJnaXZlbl9uYW1lIjoiQmVuamFtaW4iLCJsb2NhbGUiOiJmci1DQSIsIm5vbmNlIjoiTFFwUU1yZmo0Z3RKSFR3bGdkVEJYTVQ3RnNodDVKc012dDNKVjFTTyIsImF1ZCI6Ik1GX0kzMzQ2OGY1Ni1lZmY3LTRhZDgtOTM2My1jZGM3MzdiYjQwNWIiLCJhY3IiOiIwIiwib3JnLmZvcmdlcm9jay5vcGVuaWRjb25uZWN0Lm9wcyI6Imk0VGJvSzJZU3NFVGVDSEUteVQ1dHVLTDF5USIsInNfaGFzaCI6IktBeUVDb3ZrQ0djcEdlSWxJc3dMREEiLCJhenAiOiJNRl9JMzM0NjhmNTYtZWZmNy00YWQ4LTkzNjMtY2RjNzM3YmI0MDViIiwiYXV0aF90aW1lIjoxNTgyMjIyNTE3LCJuYW1lIjoiQUFIUzc4MDYyIiwicmVhbG0iOiIvY2xpZW50cyIsImV4cCI6MTU4MjIyMzQxNywidG9rZW5UeXBlIjoiSldUVG9rZW4iLCJmYW1pbHlfbmFtZSI6IkRlc21hcmFpcyIsImlhdCI6MTU4MjIyMjUxNywiZW1haWwiOiJoeWRyb3F1ZWJlY19tb25pdG9yQGhkZW5lcmdpZS5jYSJ9.F3wzNAdPAjoI6Arv8xu1oS1P3ZL4dSyWkGhgWIB0io5oXShW2-oni77ppVjTfe1uFhkGNF7efx2kOSoqpk_0LTGb_yiNEHdffGkDmsywiZjqbmTah7lu0PU5TQIQxhu-pb2lC-PWc_sg9V78BIyt-nw3fZ74TrVNb4UNG0LskhKzz6w5oRu7J4bH0wqZpY6yJ2cbvX-W1uSlU8cynoc7dRAQHHiE5vSQu2fsbfrMl09T2r4uSsNY2PpjaPGRybONLCKJNpx3UbRjwFSRPNHsSiSw96D2DoZzWAIBXkZyHy_R74d-nbs0DLEgspKOIuKEHovbXWxAjGwqIJl9TeYyxzmH0Urbtel43HKMcp9ePVoVAE9SOeCb3V9uXCW8WVR9jBp3A1AwxDChc2uXc3Ee71yQEYunEeZDISsAAKLj2noIWtIMdlL28-t2Y_PzyRPKZ60MwYDCug1250YXoyT5k-ZWt3WYHz9mxX5nVLO_WghddeZ17hV56VSGZjHei2AsfE4ngi_bPxvNCgjwPe1FXIMjf9eclIvaBkyNWllkWGyjL_uNnqJ5M9vmpLBb_9zNe5sHHdV0T-RAQjMzzNQkaWJyXbC02bW6KbMv2RhbGzUcN6v87GrY9M9nzZhcvRZ-oyQA0FDCkp2vrhSO-8qtIk7XAwk55kJND0n6IioYRXU&state=LQpQMrfj4gtJHTwlgdTBXMT7Fsht5JsMvt3JV1SO&token_type=Bearer&expires_in=899'
I dont know if its possible to change the expires_in parameter to make it longer or simply to have a way to relogin if the token expires after those 899 seconds or 15 minutes.

The Deamon won't find my contract ids.

Describe the bug
The Deamon won't find my contract ids. See the log output.

To Reproduce
Steps to reproduce the behavior:

Fetch the code from github:
git clone [email protected]:titilambert/pyhydroquebec.git

Run it:
docker-compose -f docker-compose.yaml up pyhydroquebec

Simplified version of docker-compose.yaml file:

version: '3.1'

services:
  eclipse-mosquitto:
    container_name: eclipse-mosquitto
    image: eclipse-mosquitto:latest
    ports:
      - 1883:1883
      - 9001:9001
    volumes:
      - ./mosquitto.conf:/mosquitto/config/mosquitto.conf
      - ./mosquitto_passwd:/etc/mosquitto/passwd:ro
      - eclipse-mosquito-data:/mosquitto/data
      - eclipse-mosquito-log:/mosquitto/log

  pyhydroquebec:
    build: ./pyhydroquebec
    volumes:
      - ./pyhydroquebec_config.yaml:/etc/pyhydroquebec/pyhydroquebec.yaml:ro
    env_file:
      pyhydroquebec-variables.env

pyhydroquebec-variables.env file:

MQTT_USERNAME=mqtt_username
MQTT_PASSWORD=mqtt_password
MQTT_HOST=eclipse-mosquitto
MQTT_PORT=1883
PYHQ_OUTPUT=MQTT

pyhydroquebec_config.yaml file:

# THIS YAML CAN CHANGE IN THE FUTURE
timeout: 30
# If frequency is not set the "daemon" will collect the data only one time and stop
# 6 hours
frequency: 8640
accounts:
- username: "MY_EMAIL_ADDRESS"
  password: "MY_PASSWORD"
  contracts:
    - id: "333333333"
    - id: "444444444"

docker logs output:

(...)
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:27,211 - INFO - pyhydroquebec - Selecting customer 5555555555
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:27,212 - DEBUG - pyhydroquebec - HTTP query https://cl-services.idp.hydroquebec.com/cl/prive/api/v3_0/partenaires/infoBase to get
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:27,460 - DEBUG - pyhydroquebec - HTTP query https://cl-ec-spring.hydroquebec.com/portail/prive/maj-session/ to get
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:28,115 - DEBUG - pyhydroquebec - HTTP query https://cl-ec-spring.hydroquebec.com/portail/fr/group/clientele/gerer-mon-compte/ to get
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:29,227 - DEBUG - pyhydroquebec - HTTP query https://cl-ec-spring.hydroquebec.com/portail/fr/group/clientele/portrait-de-consommation to get
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:29,639 - INFO - pyhydroquebec - Customer 5555555555 selected
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:29,639 - DEBUG - pyhydroquebec - HTTP query https://cl-ec-spring.hydroquebec.com/portail/fr/group/clientele/gerer-mon-compte/ to get
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:30,607 - INFO - pyhydroquebec.customer.5555555555 - Customer has no contract
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:30,608 - DEBUG - pyhydroquebec - HTTP query https://cl-ec-spring.hydroquebec.com/portail/fr/group/clientele/portrait-de-consommation to get
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:30,923 - WARNING - mqtt-hydroquebec - Contract 333333333 not found
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:30,923 - WARNING - mqtt-hydroquebec - Contract 444444444 not found
pyhydroquebec_1_a96773151419 | 2019-12-29 01:17:30,926 - INFO - mqtt-hydroquebec - Waiting for 8640 seconds before the next check

Expected behavior
The deamon would run and publish data on mqtt.

PyHydroQuebec and Python version
Please write here which version of Python and PyHydroQuebec you are using.

pyhydroquebec==3.0.0

python version: python:3.7-alpine

Architecture: ARM (Raspberry Pi 3 Model B Rev 1.2)

Hydroquebec rate

Select your rate:

  • D (For the second account)
  • DP
  • DM
  • DT (For the main account)

Hydroquebec multi-contract
Do you have more than one contract with HydroQuebec ?

  • Yes (2)
  • No

Corner Cases
Are you in one of this situations:

  • Change of address
  • Change of rate
  • Add a new contract
  • Remove an old contract
  • No
  • Other:

Add

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

pyhydroquebec COMPLETE THIS

Expected behavior
A clear and concise description of what you expected to happen.

PyHydroQuebec and Python version
Please write here which version of Python and PyHydroQuebec you are using.

Hydroquebec rate

Select your rate:

  • D
  • DP
  • DM
  • DT

Hydroquebec multi-contract
Do you have more than one contract with HydroQuebec ?

  • Yes
  • No

Corner Cases
Are you in one of this situations:

  • Change of address
  • Change of rate
  • Add a new contract
  • Remove an old contract
  • No
  • Other:

Additional context
Add any other context about the problem here.

Failing pip install

Hi!

This package is failing during pip install in home assistant Travis builds. The error message says that there's no module named pip.req, which setup.py is relying on.

https://travis-ci.org/home-assistant/home-assistant/jobs/367048309

This could possibly be related to pip releasing 10.0. I haven't reproduced this locally yet. I'll try to do that soon.

Edit:
Ok, I've reproduced the error locally in a fresh venv with pip 10.0.0:

(pyhydroquebec) martin@martin-ThinkPad-T460s:~$ pip install pyhydroquebec
Collecting pyhydroquebec
  Downloading pyhydroquebec-2.2.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-xl9rezok/pyhydroquebec/setup.py", line 3, in <module>
        from pip.req import parse_requirements
    ModuleNotFoundError: No module named 'pip.req'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-xl9rezok/pyhydroquebec/

Downgrading to pip 9.0.3 successfully installs this package:

(pyhydroquebec) martin@martin-ThinkPad-T460s:~$ pip install "pip<10.0"
Collecting pip<10.0
  Using cached pip-9.0.3-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 10.0.0
    Uninstalling pip-10.0.0:
      Successfully uninstalled pip-10.0.0
Successfully installed pip-9.0.3
You are using pip version 9.0.3, however version 10.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(pyhydroquebec) martin@martin-ThinkPad-T460s:~$ pip install pyhydroquebec
Collecting pyhydroquebec
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading pyhydroquebec-2.2.1.tar.gz
Collecting aiohttp (from pyhydroquebec)
  Downloading aiohttp-3.1.3-cp36-cp36m-manylinux1_x86_64.whl (661kB)
    100% |████████████████████████████████| 665kB 882kB/s 
Collecting bs4 (from pyhydroquebec)
  Downloading bs4-0.0.1.tar.gz
Collecting async-timeout<3.0,>=1.2 (from aiohttp->pyhydroquebec)
  Using cached async_timeout-2.0.1-py3-none-any.whl
Collecting multidict<5.0,>=4.0 (from aiohttp->pyhydroquebec)
  Downloading multidict-4.2.0-cp36-cp36m-manylinux1_x86_64.whl (473kB)
    100% |████████████████████████████████| 481kB 1.0MB/s 
Collecting chardet<4.0,>=2.0 (from aiohttp->pyhydroquebec)
  Cache entry deserialization failed, entry ignored
  Using cached chardet-3.0.4-py2.py3-none-any.whl
Collecting idna-ssl>=1.0 (from aiohttp->pyhydroquebec)
  Downloading idna-ssl-1.0.1.tar.gz
Collecting attrs>=17.3.0 (from aiohttp->pyhydroquebec)
  Using cached attrs-17.4.0-py2.py3-none-any.whl
Collecting yarl<2.0,>=1.0 (from aiohttp->pyhydroquebec)
  Downloading yarl-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (255kB)
    100% |████████████████████████████████| 256kB 1.1MB/s 
Collecting beautifulsoup4 (from bs4->pyhydroquebec)
  Using cached beautifulsoup4-4.6.0-py3-none-any.whl
Collecting idna>=2.0 (from idna-ssl>=1.0->aiohttp->pyhydroquebec)
  Cache entry deserialization failed, entry ignored
  Using cached idna-2.6-py2.py3-none-any.whl
Building wheels for collected packages: pyhydroquebec, bs4, idna-ssl
  Running setup.py bdist_wheel for pyhydroquebec ... done
  Stored in directory: /home/martin/.cache/pip/wheels/95/b8/e3/2bf5cc801f005e18ff7fd664f61238e99376e246b5739d02bf
  Running setup.py bdist_wheel for bs4 ... done
  Stored in directory: /home/martin/.cache/pip/wheels/84/67/d4/9e09d9d5adede2ee1c7b7e8775ba3fbb04d07c4f946f0e4f11
  Running setup.py bdist_wheel for idna-ssl ... done
  Stored in directory: /home/martin/.cache/pip/wheels/b8/01/3c/37f9f2ab95297ba796465c4094345eb22f247df1a9096ad0ba
Successfully built pyhydroquebec bs4 idna-ssl
Installing collected packages: async-timeout, multidict, chardet, idna, idna-ssl, attrs, yarl, aiohttp, beautifulsoup4, bs4, pyhydroquebec
Successfully installed aiohttp-3.1.3 async-timeout-2.0.1 attrs-17.4.0 beautifulsoup4-4.6.0 bs4-0.0.1 chardet-3.0.4 idna-2.6 idna-ssl-1.0.1 multidict-4.2.0 pyhydroquebec-2.2.1 yarl-1.1.1
You are using pip version 9.0.3, however version 10.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

HassOS addon

Is there an HassOS addon to install and use the mqtt daemon on HassOS?

Unclosed client sessions

Hi,

I get this error when i run the the -j flag. The data prints fine, but the session is not closed?

Unclosed client session client_session: <aiohttp.client.ClientSession object at 0x000001E116C6CDA0> Unclosed connector connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x000001E11774E908>, 343340.5 93)]'] connector: <aiohttp.connector.TCPConnector object at 0x000001E116C6CE10> Unclosed connection client_connection: Connection<ConnectionKey(host='www.hydroquebec.com', port=443, ssl=True)

Any idea what caused it?

KeyError: 'yesterday_hourly_consumption'

Describe the bug
Error when running the -H option
2018-12-01 15_22_52-select pi raspcatfeeder_

When running the -j:
{"contractNumber": {"period_total_bill": Number, "annual_date_end": "", "period_average_temperature": -2, "annual_date_start": "", "period_mean_daily_bill": Number, "annual_total_consumption": "", "balance": 0.0, "period_projection": Number, "yesterday_lower_price_consumption": Number, "annual_mean_daily_consumption": "", "yesterday_higher_price_consumption": 0, "annual_kwh_price_cent": "", "period_total_days": 61, "annual_length": "", "period_lower_price_consumption": Number, "period_mean_daily_consumption": Number, "period_higher_price_consumption": 0, "yesterday_total_consumption": Number, "period_length": 42, "period_total_consumption": Number, "yesterday_average_temperature": -3, "annual_mean_daily_bill": "", "annual_total_bill": ""}}

yesterday_hourly_consumption is not there

Running witouth -H dons't feedback error

Python 3.10 - sslv3 handshake

Describe the bug
On Python 3.10, running pyhydroquebec -u MYACCOUNT -p MYPASSWORD --list-contracts
Getting this error:

/usr/local/lib/python3.10/site-packages/aiohttp/connector.py:964: RuntimeWarning: coroutine 'TCPConnector._resolve_host' was never awaited
  hosts = await asyncio.shield(self._resolve_host(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
shield() got an unexpected keyword argument 'loop'

To Reproduce
Steps to reproduce the behavior:

# get the latest python version 3.10
docker run -it --rm python:latest bash
pip install pyhydroquebec 
pyhydroquebec -u MYACCOUNT -p MYPASSWORD --list-contracts

Expected behavior

Contract: 111111111
        Account: 0000000000
        Customer: 0000000000

PyHydroQuebec and Python version
Python: 3.10
PyHydroQuebec: 3.0.5

Hydroquebec rate

Select your rate:

  • [X ] D
  • DP
  • DM
  • DT

Hydroquebec multi-contract
Do you have more than one contract with HydroQuebec ?

  • Yes
  • [ X] No

Corner Cases
Are you in one of this situations:

  • Change of address
  • Change of rate
  • Add a new contract
  • Remove an old contract
  • [X ] No
  • Other:

Additional context
I was able to revert back to Python 3.9.7 and its working properly.

average_temperature from current_daily_data can be None

Describe the bug
If you query HQ close to midnight, data is still being rolled out.
One corner case is already taken care of (yesterday - 1).
But, HQ will release the consumption without average_temperature.

image

If you query during this interval, you get None and code can crash.

Traceback (most recent call last):
  File "/usr/local/bin/pyhydroquebec", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/pyhydroquebec/__main__.py", line 168, in main
    output_text(results[0], args.hourly)
  File "/usr/local/lib/python3.7/site-packages/pyhydroquebec/outputter.py", line 24, in output_text
    print(YESTERDAY_TPL.format(d=data))
TypeError: unsupported format string passed to NoneType.__format__

To Reproduce
Run the std use case

pyhydroquebec -u XXX -p XXX

Expected behavior
No errors. :)

PyHydroQuebec and Python version
Python 3.7.5
PyHydroQuebec 3.0.0 (master as of today)

Corner Cases
Are you in one of this situations:

  • Change of address
  • Change of rate
  • Add a new contract
  • Remove an old contract
  • No
  • Other: query close to midnight (2AM in my test)

No module named 'aiohttp'

Describe the bug
Installation of the package fails due to the setup script requiring aiohttp prior due to how the module is loaded to obtain the version prior to requirements installation.

To Reproduce
Steps to reproduce the behavior:

  1. Create an empty virtual environment (python -m venv venv)
  2. Activate the environment (.\venv\scripts\activate)
  3. Attempt to install the package (pip install pyhydroquebec)
Collecting pyhydroquebec
  Downloading https://files.pythonhosted.org/packages/50/dd/ea8437dfacfa7b758b98574a016b662b67acc7641e97e07b2c9ac45951c3/pyhydroquebec-2.4.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "Temp\pip-install-xdmsft7t\pyhydroquebec\setup.py", line 4, in <module>
        from pyhydroquebec.__main__ import VERSION
      File "Temp\pip-install-xdmsft7t\pyhydroquebec\pyhydroquebec\__init__.py", line 2, in <module>
        from pyhydroquebec.client import HydroQuebecClient, REQUESTS_TIMEOUT, HQ_TIMEZONE  # NOQA
      File "Temp\pip-install-xdmsft7t\pyhydroquebec\pyhydroquebec\client.py", line 7, in <module>
        import aiohttp
    ModuleNotFoundError: No module named 'aiohttp'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in Temp\pip-install-xdmsft7t\pyhydroquebec\

Expected behavior
Package setup script should be able to run without assumed dependencies.

PyHydroQuebec and Python version
pyhydroquebec 2.4.0, any supported python version.

Could not get annual data

Hi,

I am having issues since HQ release the new format. The short error I get is the following :
[homeassistant.components.sensor.hydroquebec] Error on receive last Hydroquebec data: Could not get annual data

This contract was working properly previously. One thing that may be related is that this contract is new since the beginning of March 2017 so in the new HQ webpage I don't have access to any of the following features yet:

https://www.hydroquebec.com/portail/group/clientele/portrait-de-consommation

  • I don't have the "Comparer à l'an dernier" switch under "Vue d'ensemble - période en cours" and "Historique", it is grayed out.
    image

See below for the full log. I edited out the contract number.

Dec 08 13:14:05 ha hass[13925]: 2017-12-08 13:14:05 WARNING (MainThread) [homeassistant.helpers.entity] Update of sensor.hydroquebec_yesterday_total_consumption is taking over 10 seconds
Dec 08 13:14:11 ha hass[13925]: 2017-12-08 13:14:11 ERROR (Thread-35) [homeassistant.components.sensor.hydroquebec] Error on receive last Hydroquebec data: Could not get annual data
Dec 08 13:14:11 ha hass[13925]: 2017-12-08 13:14:11 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.hydroquebec_yesterday_total_consumption fails
Dec 08 13:14:11 ha hass[13925]: Traceback (most recent call last):
Dec 08 13:14:11 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 199, in async_update_ha_state
Dec 08 13:14:11 ha hass[13925]:     yield from self.async_device_update()
Dec 08 13:14:11 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 306, in async_device_update
Dec 08 13:14:11 ha hass[13925]:     yield from self.hass.async_add_job(self.update)
Dec 08 13:14:11 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
Dec 08 13:14:11 ha hass[13925]:     yield self  # This tells Task to wait for completion.
Dec 08 13:14:11 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
Dec 08 13:14:11 ha hass[13925]:     future.result()
Dec 08 13:14:11 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
Dec 08 13:14:11 ha hass[13925]:     raise self._exception
Dec 08 13:14:11 ha hass[13925]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
Dec 08 13:14:11 ha hass[13925]:     result = self.fn(*self.args, **self.kwargs)
Dec 08 13:14:11 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 157, in update
Dec 08 13:14:11 ha hass[13925]:     self.hydroquebec_data.update()
Dec 08 13:14:11 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 306, in wrapper
Dec 08 13:14:11 ha hass[13925]:     result = method(*args, **kwargs)
Dec 08 13:14:11 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 192, in update
Dec 08 13:14:11 ha hass[13925]:     self.data = self.client.get_data(self._contract)[self._contract]
Dec 08 13:14:11 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/pyhydroquebec/client.py", line 337, in get_data
Dec 08 13:14:11 ha hass[13925]:     raise PyHydroQuebecError("Contract {} not found".format(contract))
Dec 08 13:14:11 ha hass[13925]: pyhydroquebec.client.PyHydroQuebecError: Contract "Edited out" not found
Dec 08 13:14:19 ha hass[13925]: 2017-12-08 13:14:19 ERROR (Thread-42) [homeassistant.components.sensor.hydroquebec] Error on receive last Hydroquebec data: Could not get annual data
Dec 08 13:14:19 ha hass[13925]: 2017-12-08 13:14:19 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.hydroquebec_period_total_bill fails
Dec 08 13:14:19 ha hass[13925]: Traceback (most recent call last):
Dec 08 13:14:19 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 199, in async_update_ha_state
Dec 08 13:14:19 ha hass[13925]:     yield from self.async_device_update()
Dec 08 13:14:19 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 306, in async_device_update
Dec 08 13:14:19 ha hass[13925]:     yield from self.hass.async_add_job(self.update)
Dec 08 13:14:19 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
Dec 08 13:14:19 ha hass[13925]:     yield self  # This tells Task to wait for completion.
Dec 08 13:14:19 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
Dec 08 13:14:19 ha hass[13925]:     future.result()
Dec 08 13:14:19 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
Dec 08 13:14:19 ha hass[13925]:     raise self._exception
Dec 08 13:14:19 ha hass[13925]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
Dec 08 13:14:19 ha hass[13925]:     result = self.fn(*self.args, **self.kwargs)
Dec 08 13:14:19 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 157, in update
Dec 08 13:14:19 ha hass[13925]:     self.hydroquebec_data.update()
Dec 08 13:14:19 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 306, in wrapper
Dec 08 13:14:19 ha hass[13925]:     result = method(*args, **kwargs)
Dec 08 13:14:19 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 192, in update
Dec 08 13:14:19 ha hass[13925]:     self.data = self.client.get_data(self._contract)[self._contract]
Dec 08 13:14:19 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/pyhydroquebec/client.py", line 337, in get_data
Dec 08 13:14:19 ha hass[13925]:     raise PyHydroQuebecError("Contract {} not found".format(contract))
Dec 08 13:14:19 ha hass[13925]: pyhydroquebec.client.PyHydroQuebecError: Contract "Edited out" not found
Dec 08 13:14:27 ha hass[13925]: 2017-12-08 13:14:27 ERROR (Thread-11) [homeassistant.components.sensor.hydroquebec] Error on receive last Hydroquebec data: Could not get annual data
Dec 08 13:14:27 ha hass[13925]: 2017-12-08 13:14:27 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.hydroquebec_period_mean_daily_consumption fails
Dec 08 13:14:27 ha hass[13925]: Traceback (most recent call last):
Dec 08 13:14:27 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 199, in async_update_ha_state
Dec 08 13:14:27 ha hass[13925]:     yield from self.async_device_update()
Dec 08 13:14:27 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 306, in async_device_update
Dec 08 13:14:27 ha hass[13925]:     yield from self.hass.async_add_job(self.update)
Dec 08 13:14:27 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
Dec 08 13:14:27 ha hass[13925]:     yield self  # This tells Task to wait for completion.
Dec 08 13:14:27 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
Dec 08 13:14:27 ha hass[13925]:     future.result()
Dec 08 13:14:27 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
Dec 08 13:14:27 ha hass[13925]:     raise self._exception
Dec 08 13:14:27 ha hass[13925]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
Dec 08 13:14:27 ha hass[13925]:     result = self.fn(*self.args, **self.kwargs)
Dec 08 13:14:27 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 157, in update
Dec 08 13:14:27 ha hass[13925]:     self.hydroquebec_data.update()
Dec 08 13:14:27 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 306, in wrapper
Dec 08 13:14:27 ha hass[13925]:     result = method(*args, **kwargs)
Dec 08 13:14:27 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 192, in update
Dec 08 13:14:27 ha hass[13925]:     self.data = self.client.get_data(self._contract)[self._contract]
Dec 08 13:14:27 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/pyhydroquebec/client.py", line 337, in get_data
Dec 08 13:14:27 ha hass[13925]:     raise PyHydroQuebecError("Contract {} not found".format(contract))
Dec 08 13:14:27 ha hass[13925]: pyhydroquebec.client.PyHydroQuebecError: Contract "Edited out" not found
Dec 08 13:14:36 ha hass[13925]: 2017-12-08 13:14:36 ERROR (Thread-21) [homeassistant.components.sensor.hydroquebec] Error on receive last Hydroquebec data: Could not get annual data
Dec 08 13:14:36 ha hass[13925]: 2017-12-08 13:14:36 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.hydroquebec_balance fails
Dec 08 13:14:36 ha hass[13925]: Traceback (most recent call last):
Dec 08 13:14:36 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 199, in async_update_ha_state
Dec 08 13:14:36 ha hass[13925]:     yield from self.async_device_update()
Dec 08 13:14:36 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 306, in async_device_update
Dec 08 13:14:36 ha hass[13925]:     yield from self.hass.async_add_job(self.update)
Dec 08 13:14:36 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
Dec 08 13:14:36 ha hass[13925]:     yield self  # This tells Task to wait for completion.
Dec 08 13:14:36 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
Dec 08 13:14:36 ha hass[13925]:     future.result()
Dec 08 13:14:36 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
Dec 08 13:14:36 ha hass[13925]:     raise self._exception
Dec 08 13:14:36 ha hass[13925]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
Dec 08 13:14:36 ha hass[13925]:     result = self.fn(*self.args, **self.kwargs)
Dec 08 13:14:36 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 157, in update
Dec 08 13:14:36 ha hass[13925]:     self.hydroquebec_data.update()
Dec 08 13:14:36 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 306, in wrapper
Dec 08 13:14:36 ha hass[13925]:     result = method(*args, **kwargs)
Dec 08 13:14:36 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 192, in update
Dec 08 13:14:36 ha hass[13925]:     self.data = self.client.get_data(self._contract)[self._contract]
Dec 08 13:14:36 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/pyhydroquebec/client.py", line 337, in get_data
Dec 08 13:14:36 ha hass[13925]:     raise PyHydroQuebecError("Contract {} not found".format(contract))
Dec 08 13:14:36 ha hass[13925]: pyhydroquebec.client.PyHydroQuebecError: Contract "Edited out" not found
Dec 08 13:14:44 ha hass[13925]: 2017-12-08 13:14:44 ERROR (Thread-10) [homeassistant.components.sensor.hydroquebec] Error on receive last Hydroquebec data: Could not get annual data
Dec 08 13:14:44 ha hass[13925]: 2017-12-08 13:14:44 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.hydroquebec_period_mean_daily_bill fails
Dec 08 13:14:44 ha hass[13925]: Traceback (most recent call last):
Dec 08 13:14:44 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 199, in async_update_ha_state
Dec 08 13:14:44 ha hass[13925]:     yield from self.async_device_update()
Dec 08 13:14:44 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/helpers/entity.py", line 306, in async_device_update
Dec 08 13:14:44 ha hass[13925]:     yield from self.hass.async_add_job(self.update)
Dec 08 13:14:44 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 361, in __iter__
Dec 08 13:14:44 ha hass[13925]:     yield self  # This tells Task to wait for completion.
Dec 08 13:14:44 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/tasks.py", line 296, in _wakeup
Dec 08 13:14:44 ha hass[13925]:     future.result()
Dec 08 13:14:44 ha hass[13925]:   File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
Dec 08 13:14:44 ha hass[13925]:     raise self._exception
Dec 08 13:14:44 ha hass[13925]:   File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
Dec 08 13:14:44 ha hass[13925]:     result = self.fn(*self.args, **self.kwargs)
Dec 08 13:14:44 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 157, in update
Dec 08 13:14:44 ha hass[13925]:     self.hydroquebec_data.update()
Dec 08 13:14:44 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/util/__init__.py", line 306, in wrapper
Dec 08 13:14:44 ha hass[13925]:     result = method(*args, **kwargs)
Dec 08 13:14:44 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/sensor/hydroquebec.py", line 192, in update
Dec 08 13:14:44 ha hass[13925]:     self.data = self.client.get_data(self._contract)[self._contract]
Dec 08 13:14:44 ha hass[13925]:   File "/srv/homeassistant/lib/python3.5/site-packages/pyhydroquebec/client.py", line 337, in get_data
Dec 08 13:14:44 ha hass[13925]:     raise PyHydroQuebecError("Contract {} not found".format(contract))
Dec 08 13:14:44 ha hass[13925]: pyhydroquebec.client.PyHydroQuebecError: Contract "Edited out" not found

Error while setting up platform hydroquebec

Hi Guys
Since 2 September I'm unable to get data from hydroquebec, when I swap for my father account
he works ......
When I put my information (single account) this is the ouput from hass:
`Error while setting up platform hydroquebec

Traceback (most recent call last):
File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
return fut.result()
File "/usr/src/app/homeassistant/components/sensor/hydroquebec.py", line 110, in async_setup_platform
contracts = yield from hydroquebec_data.get_contract_list()
File "/usr/src/app/homeassistant/components/sensor/hydroquebec.py", line 181, in get_contract_list
ret = yield from self._fetch_data()
File "/usr/src/app/homeassistant/components/sensor/hydroquebec.py", line 191, in _fetch_data
await self.client.fetch_data()
File "/usr/local/lib/python3.6/site-packages/pyhydroquebec/client.py", line 387, in fetch_data
daily_data = yield from self._get_daily_data(p_p_id, start_date, end_date)
File "/usr/local/lib/python3.6/site-packages/pyhydroquebec/client.py", line 276, in _get_daily_data
timeout=self._timeout)
File "/usr/local/lib/python3.6/site-packages/aiohttp/client.py", line 361, in _request
ssl=ssl, proxy_headers=proxy_headers, traces=traces)
File "/usr/local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 207, in init
url2 = url.with_query(params)
File "/usr/local/lib/python3.6/site-packages/yarl/init.py", line 857, in with_query
new_query = self._get_str_query(*args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/yarl/init.py", line 825, in _get_str_query
"should be str or int, got {!r}".format(v))
TypeError: Invalid variable type: mapping value should be str or int, got None
`

Output needs some work

Some tables are misaligned. Can be fixed trivially with tabulate, as long as you're fine with new deps. Or at the very least, the output can be templated using jinja.

To reproduce, here's a very simple call, I'm assuming it's misaligned for everyone:

> pyhydroquebec -H

which results in a misaligned table:

-----------------------------
   Hour  | Temperature | Lower price consumption | Higher price consumption | total comsumption

   0:00  |     10     |     0.14     |     0.00     |     0.14  
   1:00  |      9     |     0.23     |     0.00     |     0.23  

(...)

  22:00  |     16     |     0.61     |     0.00     |     0.61  
  23:00  |     16     |     0.73     |     0.00     |     0.73 

Anyway -- care for a PR?

Broken with aiohttp==3.2.1

I think pyhydroquebec is broken with the last version of home-assistant that use aiohttp==3.2.1

2018-06-11 15:25:00 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform hydroquebec
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.5/asyncio/tasks.py", line 400, in wait_for
    return fut.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
    result = coro.send(None)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/hydroquebec.py", line 109, in async_setup_platform
    contracts = yield from hydroquebec_data.get_contract_list()
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/hydroquebec.py", line 180, in get_contract_list
    ret = yield from self._fetch_data()
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/hydroquebec.py", line 190, in _fetch_data
    await self.client.fetch_data()
  File "/opt/home-assistant/deps/lib/python3.5/site-packages/pyhydroquebec/client.py", line 387, in fetch_data
    daily_data = yield from self._get_daily_data(p_p_id, start_date, end_date)
  File "/opt/home-assistant/deps/lib/python3.5/site-packages/pyhydroquebec/client.py", line 276, in _get_daily_data
    timeout=self._timeout)
  File "/opt/home-assistant/deps/lib/python3.5/site-packages/aiohttp/client.py", line 313, in _request
    ssl=ssl, proxy_headers=proxy_headers, traces=traces)
  File "/opt/home-assistant/deps/lib/python3.5/site-packages/aiohttp/client_reqrep.py", line 191, in __init__
    url2 = url.with_query(params)
  File "/opt/home-assistant/deps/lib/python3.5/site-packages/yarl/__init__.py", line 851, in with_query
    new_query = self._get_str_query(*args, **kwargs)
  File "/opt/home-assistant/deps/lib/python3.5/site-packages/yarl/__init__.py", line 819, in _get_str_query
    "should be str or int, got {!r}".format(v))
TypeError: Invalid variable type: mapping value should be str or int, got None

Contract xxxx not found with home-assistant

All information are Good (contract, password...), i try with different version of pyhydroquebec. Last version tried : 2.1.0

But if i try directly hydroquebec it's work

2018-01-05 09:32:30 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.hydroquebec_period_total_consumption fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity.py", line 199, in async_update_ha_state
    yield from self.async_device_update()
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/helpers/entity.py", line 306, in async_device_update
    yield from self.hass.async_add_job(self.update)
  File "/usr/lib/python3.5/asyncio/futures.py", line 380, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 304, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 293, in result
    raise self._exception
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/hydroquebec.py", line 157, in update
    self.hydroquebec_data.update()
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/util/__init__.py", line 306, in wrapper
    result = method(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/homeassistant/components/sensor/hydroquebec.py", line 192, in update
    self.data = self.client.get_data(self._contract)[self._contract]
  File "/opt/home-assistant/deps/lib/python3.5/site-packages/pyhydroquebec/client.py", line 350, in get_data
    raise PyHydroQuebecError("Contract {} not found".format(contract))

Add M rate support

The fetch summary method cannot work when a customer object can have multiple contracts.

Here you can see an example for one of my client number. He has 2 different accounts on the same client number:

image

Also, to see the contract number you need to click on the (+) button next to "Electricité fournie à 1 adresse". This trigger an ajax request with get at https://cl-ec-spring.hydroquebec.com/portail/fr/group/clientele/gerer-mon-compte/actionAfficherLieuxDeConsoAjax?ncc=$accountNumber

The contrat number will be inside that response

Here is a stack trace of the current error:

'NoneType' object has no attribute 'text' File "/mnt/c/Users/kevmegforest/workspace/hydroquebec_puller/job/src/hydroquebec_puller/__main__.py", line 77, in main results = loop.run_until_complete(asyncio.gather(async_func)) File "/usr/lib/python3.7/asyncio/base_events.py", line 579, in run_until_complete return future.result() File "/mnt/c/Users/kevmegforest/workspace/hydroquebec_puller/job/src/env/lib/python3.7/site-packages/pyhydroquebec/__main__.py", line 65, in fetch_data_detailled_energy_use await client.login() File "/mnt/c/Users/kevmegforest/workspace/hydroquebec_puller/job/src/env/lib/python3.7/site-packages/pyhydroquebec/client.py", line 231, in login await customer.fetch_summary() File "/mnt/c/Users/kevmegforest/workspace/hydroquebec_puller/job/src/env/lib/python3.7/site-packages/pyhydroquebec/customer.py", line 61, in fetch_summary raw_contract_id = soup.find('div', {'class': 'contrat'}).text None

can't connect to login page

Hi

i installed pyhydroquebec but when I use "pyhydroquebec -uUSERNAME -p PASSWORD", I get an error. I could not find anything that would help me fix this in the README file.

Here is my error:

`Task exception was never retrieved
future: <Task finished name='Task-2' coro=<HydroQuebecClient.fetch_data() done, defined at c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\pyhydroquebec\client.py:394> exception=PyHydroQuebecError('Can not connect to login page')>
Traceback (most recent call last):
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\aiohttp\connector.py", line 936, in _wrap_create_connection
return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\asyncio\base_events.py", line 1046, in create_connection
transport, protocol = await self._create_connection_transport(
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\asyncio\base_events.py", line 1076, in _create_connection_transport
await waiter
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\asyncio\sslproto.py", line 529, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\asyncio\sslproto.py", line 189, in feed_ssldata
self._sslobj.do_handshake()
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\ssl.py", line 944, in do_handshake
self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\pyhydroquebec\client.py", line 76, in _get_login_page
raw_res = yield from self._session.get(HOME_URL,
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\aiohttp\client.py", line 480, in _request
conn = await self._connector.connect(
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\aiohttp\connector.py", line 523, in connect
proto = await self._create_connection(req, traces, timeout)
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\aiohttp\connector.py", line 858, in _create_connection
_, proto = await self._create_direct_connection(
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\aiohttp\connector.py", line 1004, in _create_direct_connection
raise last_exc
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\aiohttp\connector.py", line 980, in _create_direct_connection
transp, proto = await self._wrap_create_connection(
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\aiohttp\connector.py", line 938, in _wrap_create_connection
raise ClientConnectorCertificateError(
aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host www.hydroquebec.com:443 ssl:True [SSLCertVerificationError: (1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\pyhydroquebec\client.py", line 400, in fetch_data
login_url = yield from self._get_login_page()
File "c:\users\admin\appdata\local\programs\python\python38-32\lib\site-packages\pyhydroquebec\client.py", line 79, in _get_login_page
raise PyHydroQuebecError("Can not connect to login page")
pyhydroquebec.client.PyHydroQuebecError: Can not connect to login page`

Quick How to for docker

Hi Guys
One of you could you help me to start with docker version, look like not as simple as type 👍 docker run -e PYHQ_USER=*** -e PYHQ_PASSWORD=*** registry.gitlab.com/ttblt-hass/pyhydroquebec/cli:master .....
Thanks in advance, Vic

Add option to disable get_hourly_data

Hello,

I get some issues when I use daily calls to pyhydroquebec. Most of them, when I can catch the error, are related to the hourly.

Could you add an argument to disable that feature when retrieving information ?

Thanks a lot.

Connection failed due to SSL?

aiohttp fails for me... why?

time is good. Certificate of hyrdroquebec.com is valid?

File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/sslproto.py", line 493, in data_received
ssldata, appdata = self._sslpipe.feed_ssldata(data)
File "/usr/lib/python3.5/asyncio/sslproto.py", line 201, in feed_ssldata
self._sslobj.do_handshake()
File "/usr/lib/python3.5/ssl.py", line 633, in do_handshake
self._sslobj.do_handshake()
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pyhydroquebec/client.py", line 77, in _get_login_page
timeout=self._timeout)
File "/usr/local/lib/python3.5/dist-packages/aiohttp/helpers.py", line 104, in iter
ret = yield from self._coro
File "/usr/local/lib/python3.5/dist-packages/aiohttp/client.py", line 267, in _request
conn = yield from self._connector.connect(req)
File "/usr/local/lib/python3.5/dist-packages/aiohttp/connector.py", line 402, in connect
proto = yield from self._create_connection(req)
File "/usr/local/lib/python3.5/dist-packages/aiohttp/connector.py", line 749, in _create_connection
_, proto = yield from self._create_direct_connection(req)
File "/usr/local/lib/python3.5/dist-packages/aiohttp/connector.py", line 860, in _create_direct_connection
raise last_exc
File "/usr/local/lib/python3.5/dist-packages/aiohttp/connector.py", line 832, in _create_direct_connection
req=req, client_error=client_error)
File "/usr/local/lib/python3.5/dist-packages/aiohttp/connector.py", line 802, in _wrap_create_connection
raise ClientConnectorSSLError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorSSLError: Cannot connect to host session.hydroquebec.com:443 ssl:True [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/tasks.py", line 241, in _step
result = coro.throw(exc)
File "/usr/local/lib/python3.5/dist-packages/pyhydroquebec/client.py", line 400, in fetch_data
login_url = yield from self._get_login_page()
File "/usr/local/lib/python3.5/dist-packages/pyhydroquebec/client.py", line 79, in _get_login_page
raise PyHydroQuebecError("Can not connect to login page")
pyhydroquebec.client.PyHydroQuebecError: Can not connect to login page

Index out of range

Describe the bug
Error when trying to get the data from HydroQuebec

To Reproduce
The command pyhydroquebec -u username -p password (-j and witouth -j) return an error

Task exception was never retrieved
future: <Task finished coro=<HydroQuebecClient.fetch_data() done, defined at /usr/local/lib/python3.5/dist-packages/pyhydroquebec/client.py:388> exception=IndexError('list index out of range',)>
Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/usr/local/lib/python3.5/dist-packages/pyhydroquebec/client.py", line 415, in fetch_data
hourly_data = yield from self._get_hourly_data(day_date, p_p_id)
File "/usr/local/lib/python3.5/dist-packages/pyhydroquebec/client.py", line 334, in _get_hourly_data
hourly_weather_data = json_output['results'][0]['listeTemperaturesHeure']
IndexError: list index out of range

Seem linked to the fact that HydroQuebec dosn't register all the data yesterday

image

Empty list of contracts.

Describe the bug
Running pyhydroquebec -u "[email protected]" -p "abcde" --list-contracts doesn't return anything. Not even an error. Changing for a bad password throws an authentication error. So login is correct.

To Reproduce
Steps to reproduce the behavior:

pyhydroquebec -u "[email protected]" -p "abcde" --list-contracts

Expected behavior
Get the list of contracts (I have 3)

PyHydroQuebec and Python version
last version of PyHydroQuebec (git clone)
Python 3.7.6

Hydro-Québec sensor fails to init with unexpected mimetype error

Home Assistant release with the issue: 0.75.3

Operating environment (Hass.io/Docker/Windows/etc.): Docker (running in Ubuntu 18.04 virtual machine)

Description of problem:
Sensor fails to initialize with following error,

2018-08-11 22:16:19 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform hydroquebec
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/helpers/entity_platform.py", line 129, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/src/app/homeassistant/components/sensor/hydroquebec.py", line 109, in async_setup_platform
    contracts = yield from hydroquebec_data.get_contract_list()
  File "/usr/src/app/homeassistant/components/sensor/hydroquebec.py", line 180, in get_contract_list
    ret = yield from self._fetch_data()
  File "/usr/src/app/homeassistant/components/sensor/hydroquebec.py", line 190, in _fetch_data
    await self.client.fetch_data()
  File "/usr/local/lib/python3.6/site-packages/pyhydroquebec/client.py", line 372, in fetch_data
    hourly_data = yield from self._get_hourly_data(day_date, p_p_id)
  File "/usr/local/lib/python3.6/site-packages/pyhydroquebec/client.py", line 309, in _get_hourly_data
    json_output = yield from raw_res.json(content_type='text/json')
  File "/usr/local/lib/python3.6/site-packages/aiohttp/client_reqrep.py", line 927, in json
    headers=self.headers)
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8'

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

sensor:
  - platform: transmission
    host: INTERNAL_IP
    username: transmission
    password: transmission
    monitored_variables:
      #- 'current_status'
      - 'download_speed'
      - 'active_torrents'
      #- 'paused_torrents'
  - platform: hydroquebec
    username: USERNAME
    password: PASSWORD
    contract: CONTRACTNO
    monitored_variables:
#     - period_total_bill
      - period_total_consumption
#     - period_average_temperature

P.S - Duplicate of home-assistant/core#15944

Handle Corner cases

Try to handle corner cases

  • Add new contract
  • Rates change
  • Remove second contract
    ???

Web page changes announced for september 30 2019

I just received an email where they announced they will change the login setup and surely the web page contents too by September 30. (the image provided is surely not the current UI)

I don't know how this project can prepare itself for the changes.

Here is the content of the email:

Notice to business customers | September 9, 2019

Consolidating your accounts

Hello,We are pleased to announce that, as of September 30, 2019, you will be able to access all your accounts (residential, business and those for which you are a proxy holder) from the same Customer Space.We’re also making it easier to log into your Customer Space: instead of having to manage many different access codes, you’ll be able to log in with your email address.According to our files, the email address [email protected] is linked to several Customer Space accounts.

image

To consolidate your accounts, contact your agent at 1 800 463-9900, from 8:30 a.m. to 4:30 p.m., Monday to Friday.

If you would prefer to consolidate your accounts yourself, you may do so as of September 30, 2019. Simply log into each account and enter the same email address.

Thank you for your cooperation.

Yours truly,

Integration back to HomeAssistant

Hi @titilambert,
First of all, thanks for your work!

What's your plan to integrate this back to HA?
I created a custom component and am successfully polling my daily consumption back to HA (using parts of the old official component). We know this couldn't become an official integration anymore, but are we gonna provide a custom template?

Also, I ran your MQTT daemon and I see you are creating messages with the definition of a sensor. Are you planning to run the script outside HA and use MQTT Discovery?

Right now I'm running everything from custom_components as it's easier without accessing the host OS.

influx and json output not working

It seems to me that in the current version the influx and json outputs are disabled? I receive a "FIXME" exception for both. Otherwise working fine, many thanks.

'HQ_TIMEZONE' error

I don't know what to do with this error message ...

Traceback (most recent call last):
File "/home/arnaud/.local/bin/pyhydroquebec", line 11, in
load_entry_point('pyhydroquebec', 'console_scripts', 'pyhydroquebec')()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2631, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2291, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2297, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/home/arnaud/dev/pyhydroquebec13juin2018/pyhydroquebec/pyhydroquebec/main.py", line 8, in
from pyhydroquebec import HydroQuebecClient, REQUESTS_TIMEOUT, HQ_TIMEZONE
ImportError: cannot import name 'HQ_TIMEZONE'

Error when accessing account

Describe the bug

When running pyhydroquebec since this afternoor we get this error:
Error Fetching https://cl-services.idp.hydroquebec.com/cl/prive/api/v3_0/conversion/codeAcces

with mqtt we get something more detailed:
pyhydroquebec.error.PyHydroQuebecHTTPError: Error Fetching https://cl-services.idp.hydroquebec.com/cl/prive/api/v3_0/conversion/codeAcces
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x7f1f3b1c6710>

To Reproduce
Steps to reproduce the behavior:
run just pyhydroquebec -u -p

Seems that something has changed on Hydro side.

thanks for your help

ERROR: Could not build wheels for multidict

I can't install pyhydroquebec, i get the same error every time :(

Failed to build multidict
ERROR: Could not build wheels for multidict, which is required to install pyproject.toml-based projects

How can I fix this?

➜  ~ pip install pyhydroquebec
Collecting pyhydroquebec
  Using cached pyhydroquebec-3.0.5.tar.gz (13 kB)
  Preparing metadata (setup.py) ... done
Collecting aiohttp==3.6.2
  Using cached aiohttp-3.6.2-py3-none-any.whl (441 kB)
Collecting cachetools==3.1.1
  Using cached cachetools-3.1.1-py2.py3-none-any.whl (11 kB)
Collecting mqtt-hass-base==0.1.4
  Using cached mqtt-hass-base-0.1.4.tar.gz (6.9 kB)
  Preparing metadata (setup.py) ... done
Collecting PyYAML==5.1.2
  Using cached PyYAML-5.1.2.tar.gz (265 kB)
  Preparing metadata (setup.py) ... done
Collecting beautifulsoup4==4.8.1
  Using cached beautifulsoup4-4.8.1-py3-none-any.whl (101 kB)
Collecting python-dateutil==2.8.0
  Using cached python_dateutil-2.8.0-py2.py3-none-any.whl (226 kB)
Collecting yarl<2.0,>=1.0
  Downloading yarl-1.7.2-cp39-cp39-musllinux_1_1_aarch64.whl (309 kB)
     |████████████████████████████████| 309 kB 3.7 MB/s
Collecting async-timeout<4.0,>=3.0
  Using cached async_timeout-3.0.1-py3-none-any.whl (8.2 kB)
Collecting chardet<4.0,>=2.0
  Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting multidict<5.0,>=4.5
  Using cached multidict-4.7.6.tar.gz (50 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting attrs>=17.3.0
  Using cached attrs-21.3.0-py2.py3-none-any.whl (61 kB)
Collecting soupsieve>=1.2
  Using cached soupsieve-2.3.1-py3-none-any.whl (37 kB)
Collecting paho-mqtt==1.4.0
  Using cached paho-mqtt-1.4.0.tar.gz (88 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: six>=1.5 in /usr/lib/python3.9/site-packages (from python-dateutil==2.8.0->pyhydroquebec) (1.16.0)
Requirement already satisfied: idna>=2.0 in /usr/lib/python3.9/site-packages (from yarl<2.0,>=1.0->aiohttp==3.6.2->pyhydroquebec) (3.3)
Using legacy 'setup.py install' for pyhydroquebec, since package 'wheel' is not installed.
Using legacy 'setup.py install' for mqtt-hass-base, since package 'wheel' is not installed.
Using legacy 'setup.py install' for PyYAML, since package 'wheel' is not installed.
Using legacy 'setup.py install' for paho-mqtt, since package 'wheel' is not installed.
Building wheels for collected packages: multidict
  Building wheel for multidict (pyproject.toml) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 /usr/lib/python3.9/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /tmp/tmpr8s0xhyf
       cwd: /tmp/pip-install-roj1mjwa/multidict_c6453de3220f4e6f80404e80fa962314
  Complete output (37 lines):
  **********************
  * Accellerated build *
  **********************
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-aarch64-3.9
  creating build/lib.linux-aarch64-3.9/multidict
  copying multidict/__init__.py -> build/lib.linux-aarch64-3.9/multidict
  copying multidict/_multidict_base.py -> build/lib.linux-aarch64-3.9/multidict
  copying multidict/_compat.py -> build/lib.linux-aarch64-3.9/multidict
  copying multidict/_multidict_py.py -> build/lib.linux-aarch64-3.9/multidict
  copying multidict/_abc.py -> build/lib.linux-aarch64-3.9/multidict
  running egg_info
  warning: no previously-included files matching '*.pyc' found anywhere in distribution
  warning: no previously-included files found matching 'multidict/_multidict.html'
  warning: no previously-included files found matching 'multidict/*.so'
  warning: no previously-included files found matching 'multidict/*.pyd'
  warning: no previously-included files found matching 'multidict/*.pyd'
  no previously-included directories found matching 'docs/_build'
  writing manifest file 'multidict.egg-info/SOURCES.txt'
  copying multidict/__init__.pyi -> build/lib.linux-aarch64-3.9/multidict
  copying multidict/_multidict.c -> build/lib.linux-aarch64-3.9/multidict
  copying multidict/py.typed -> build/lib.linux-aarch64-3.9/multidict
  creating build/lib.linux-aarch64-3.9/multidict/_multilib
  copying multidict/_multilib/defs.h -> build/lib.linux-aarch64-3.9/multidict/_multilib
  copying multidict/_multilib/dict.h -> build/lib.linux-aarch64-3.9/multidict/_multilib
  copying multidict/_multilib/istr.h -> build/lib.linux-aarch64-3.9/multidict/_multilib
  copying multidict/_multilib/iter.h -> build/lib.linux-aarch64-3.9/multidict/_multilib
  copying multidict/_multilib/pair_list.h -> build/lib.linux-aarch64-3.9/multidict/_multilib
  copying multidict/_multilib/views.h -> build/lib.linux-aarch64-3.9/multidict/_multilib
  running build_ext
  creating build/temp.linux-aarch64-3.9
  creating build/temp.linux-aarch64-3.9/multidict
  gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -g -fno-semantic-interposition -g -fno-semantic-interposition -g -fno-semantic-interposition -DTHREAD_STACK_SIZE=0x100000 -fPIC -I/usr/include/python3.9 -c multidict/_multidict.c -o build/temp.linux-aarch64-3.9/multidict/_multidict.o -O2 -std=c99 -Wall -Wsign-compare -Wconversion -fno-strict-aliasing -pedantic
  error: command 'gcc' failed: No such file or directory
  ----------------------------------------
  ERROR: Failed building wheel for multidict
Failed to build multidict
ERROR: Could not build wheels for multidict, which is required to install pyproject.toml-based projects

Pulling hourly data into MQTT or InfluxDB

Thank you for your great work on pulling together this MQTT implementation of the legacy HASS component.

From the CLI, I am able to pull hourly data from my HQ profile; however, I am not sure how to do the same either through MQTT, or directly into InfluxDB.

Is there a way to do so? If anyone can help me figure it out, I can gladly contribute to the formal documentation.

Thanks!

TypeError exception in 2.1.0

Hi,

I am kinda new to the whole home-assistant and was very pleased to see a sensor for hydro-quebec. I am trying to use it within home-assistant 0.66.5, but I have the following error. I've tried to use the pyhydroquebec program directly and have the same issue. When I call the program with only my username and password, I can see my data but the same error occurs once my contract information is print to the console.

/srv/homeassistant/lib/python3.5/site-packages/pyhydroquebec/client.py:358: RuntimeWarning: coroutine 'ClientSession.close' was never awaited
self._session.close()
Task exception was never retrieved
future: <Task finished coro=<HydroQuebecClient.fetch_data() done, defined at /srv/homeassistant/lib/python3.5/site-packages/pyhydroquebec/client.py:286> exception=TypeError('Invalid variable type: mapping value should be str or int, got None',)>
Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/srv/homeassistant/lib/python3.5/site-packages/pyhydroquebec/client.py", line 323, in fetch_data
daily_data = yield from self._get_daily_data(p_p_id, start_date, end_date)
File "/srv/homeassistant/lib/python3.5/site-packages/pyhydroquebec/client.py", line 273, in _get_daily_data
timeout=self._timeout)
File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/client.py", line 312, in _request
ssl=ssl, proxy_headers=proxy_headers)
File "/srv/homeassistant/lib/python3.5/site-packages/aiohttp/client_reqrep.py", line 181, in init
url2 = url.with_query(params)
File "/srv/homeassistant/lib/python3.5/site-packages/yarl/init.py", line 851, in with_query
new_query = self._get_str_query(*args, **kwargs)
File "/srv/homeassistant/lib/python3.5/site-packages/yarl/init.py", line 819, in _get_str_query
"should be str or int, got {!r}".format(v))
TypeError: Invalid variable type: mapping value should be str or int, got None
Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x75f36830>
Unclosed connector
connections: ['[(<aiohttp.client_proto.ResponseHandler object at 0x754c0ef0>, 181330.768492032)]']
connector: <aiohttp.connector.TCPConnector object at 0x75f36810>
Unclosed connection
client_connection: Connection<ConnectionKey(host='www.hydroquebec.com', port=443, ssl=True)>

Any ideas?

Hydro Quebec sensors give an error fetching the balance Configuration

Hi Titilambert,
Thanks for your time building this addon. I try to reach you on Home Assistant but your last visit was Aug 17. So I decide to copy my case from home Assistant community here. https://community.home-assistant.io/t/hydro-quebec-sensors-give-an-error-fetching-the-balance/39378?source_topic_id=39381


When trying to setup HydroQuebec sensor for the first time I received an "Error while setting up platform hydroquebec". After reading the log I fount the following error:

File "/usr/lib/python3.6/site-packages/pyhydroquebec/client.py", line 185, in _get_balances
    balances.append(float(balance[:-2].replace(",", ".")))
ValueError: could not convert string to float: '-1\xa0627.47'

Balance: -1 627.47 (Yeah this is very unusual due to error in the monthly charge)
I suspect it is relate to my account been in credit (negative balance) or the space separation for the thousand.


Home Assistant release (hass --version):
0.60.1

Python release (python3 --version):
HASSIO - 3.6.3

Component/platform:
hydroquebec

Description of problem:
When trying to setup HydroQuebec sensor for the first time I received an "Error while setting up platform hydroquebec". After reading the log I strongly suspect it is because presently my account is negative.

Expected:
Show my HydroQuebec account information

Problem-relevant configuration.yaml entries and steps to reproduce:

# Weather prediction
sensor:
  - platform: hydroquebec
    username: xxxxxxxxxx
    password: xxxxxxxxxx
    contract: '#########'
    monitored_variables:
     - period_length
     - period_total_days
  1. Add the config above to configuration.yaml
  2. Restart Pi3
  3. Look at the Log

Traceback (if applicable):

Error while setting up platform hydroquebec
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 171, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 245, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/hydroquebec.py", line 108, in setup_platform
    ", ".join(hydroquebec_data.get_contract_list()))
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/hydroquebec.py", line 176, in get_contract_list
    self._fetch_data()
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/hydroquebec.py", line 183, in _fetch_data
    self.client.fetch_data()
  File "/usr/lib/python3.6/site-packages/pyhydroquebec/client.py", line 296, in fetch_data
    balances = self._get_balances()
  File "/usr/lib/python3.6/site-packages/pyhydroquebec/client.py", line 185, in _get_balances
    balances.append(float(balance[:-2].replace(",", ".")))
ValueError: could not convert string to float: '-1\xa0627.47'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.