Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Integration back to HomeAssistant #49

Open
llluis opened this issue Dec 26, 2019 · 33 comments
Open

Integration back to HomeAssistant #49

llluis opened this issue Dec 26, 2019 · 33 comments

Comments

@llluis
Copy link
Contributor

llluis commented Dec 26, 2019

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.

@richie256
Copy link

richie256 commented Dec 26, 2019

Hi @llluis ,

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

I would be very much interested about getting your code! even if it is not finished! Do you want to share?

Thanks

@llluis
Copy link
Contributor Author

llluis commented Dec 27, 2019

Hi @richie256
I'll upload it to github so everybody can use and contribute. Will come back when done.

@titilambert
Copy link
Owner

titilambert commented Dec 27, 2019

@llluis Hello !
Personally, I prefer to reduce the number of custom_components for some reasons (hass start time, maintenance, each update of the component implies a hass restart) so I'm trying to run custom stuff through MQTT.
BUT
I'm completely open to host this custom component in this repository. If you want, I can add you as contributor of pyhydroquebec, you will be able to commit the component, and review people PR for the component, and then users will be able to download the component from here.

@llluis
Copy link
Contributor Author

llluis commented Dec 27, 2019

Hey @titilambert, great idea, thanks!
I'll send you the code... Reviewing right now.

Agreed with custom stuff, but it's much more user friendly through custom_components. I'll keep this one till the MQTT is done.

Any reason to split the MQTT impl in 2, and hosting in gitlab half of it?

@titilambert
Copy link
Owner

What do you mean by:

Any reason to split the MQTT impl in 2, and hosting in gitlab half of it?

@llluis
Copy link
Contributor Author

llluis commented Dec 27, 2019

What do you mean by:

Any reason to split the MQTT impl in 2, and hosting in gitlab half of it?

You have mqtt-hass-base on gitlab and mqtt-daemon (which extends it) here. I didn't understand the separation.

I made a few changes to make it work inside HA: I thought to repackage everything to be able to create a custom_component (remove the blocking loop, for instance).

@llluis
Copy link
Contributor Author

llluis commented Dec 27, 2019

hydroquebec_custom.zip

There you go. Delete after import.

@Normand9999
Copy link

Hi llluis, I am using your custom component and so far I am able to get both sensors (yesterday_total_consumption and yesterday_average_temperature) but unless I restart HA I don't get updated data every day. Any ideas what is the issue. Thks .

@llluis
Copy link
Contributor Author

llluis commented Jan 8, 2020

@Normand9999, I fixed 2-3 bugs already since I posted this. I was waiting on @titilambert to publish the code so I could commit the changes. This includes a change in this lib for which I submitted a pull request. There is still one bug I couldn't fix to have it updating everyday without errors, I'm still in the learning curve of HomeAssistant HTTP session. As soon as I get it fixed, I'll share.

@llluis
Copy link
Contributor Author

llluis commented Jan 16, 2020

For all of you waiting, I published the working version at https://github.com/llluis/home-assistant/tree/master/config/custom_components/hydroquebec

Note that it will pull my pyhydroquebec fork, which contains minor changes to work on HA.

@MattL0
Copy link

MattL0 commented Feb 3, 2020

@llluis how do you install this and run this on home assistant

@ThierryBegin
Copy link

I've been able to make pyhydroquebec work on Version 3.0.0 but now I'm also struggling on understanding on how to make it work through MQTT or directly with Home Assistant

@p0pp3t0n
Copy link

So i got this working for home assistant. These are the steps that i did.
I'm running Home Assistant 0.108.3 using venv python 3.8 on centos7.

  1. Download the file from @llluis repo. I'm putting them in my .config/homeassistant/hydroquebec
    It's possible that you might not have that folder. Just create it.
    wget https://raw.githubusercontent.com/llluis/home-assistant/master/config/custom_components/hydroquebec/sensor.py
    wget https://raw.githubusercontent.com/llluis/home-assistant/master/config/custom_components/hydroquebec/manifest.json
    wget https://raw.githubusercontent.com/llluis/home-assistant/master/config/custom_components/hydroquebec/__init__.py

  2. I downloaded the requirements manually. The deps/ is found in my .config/.homeassistant/deps

pip install --target deps/ --no-dependencies https://github.com/llluis/pyhydroquebec/archive/master.zip#pyhydroquebec==3.0.5

  1. Put the configuration in your configuration.yaml. It only has those 4 sensor types.
    To find your contract number just log in the hydroquebec website and look for it.

sensor:

  • platform: hydroquebec
    username: youremail@me.com
    password: hunter2
    contract: '123456778'
    monitored_variables:
    • yesterday_total_consumption
    • yesterday_lower_price_consumption
    • yesterday_higher_price_consumption
    • yesterday_average_temperature
  1. Verify your configuration and if everything is good restart HA. You should see it in the entities.
    In my case i didn't use the yesterday_average_temparature. This reflects in the screenshot.

image

image

I hope this helps someone.

Cheers.

@QcVictor
Copy link

tks p0pp3t0n, got it working on docker with your explanation

@ThierryBegin
Copy link

I'm using hassio so i'm not sure how to get it to work
Iget Platform error sensor.hydroquebec - No module named 'pyhydroquebec'
most likely because I can't run the pip command... anyone know where I should put it?

@QcVictor
Copy link

After rebooting all sensors from hydro quebec are gone ! not sure what happen nothing in the logs about that..

@betelz
Copy link

betelz commented Jul 13, 2020

I'm using hassio so i'm not sure how to get it to work
Iget Platform error sensor.hydroquebec - No module named 'pyhydroquebec'
most likely because I can't run the pip command... anyone know where I should put it?

I'm on the same boat. Running hassio and can't run pip3 install. I also get the same No module named 'pyhydroquebec' error.

@lucboudreau
Copy link

This may help some people trying to get Hydro Quebec data back into their HA instance. My solution was to host a docker container with docker-compose. The data is sent to my MQTT server. The sensors are recognized by HA and automatically configured.

Below is the abridged docker-compose configuration I've used.

  pyhydroquebec:
    container_name: pyhydroquebec
    image: registry.gitlab.com/ttblt-hass/pyhydroquebec/mqtt:master
    volumes:
      - /home/user/pyhydroquebec:/etc/pyhydroquebec
    restart: unless-stopped
    environment:
        - MQTT_USERNAME=user
        - MQTT_PASSWORD=password
        - MQTT_HOST=X.X.X.X
        - MQTT_PORT=1883
        - ROOT_TOPIC=homeassistant
        - MQTT_NAME=pyhydroquebec
        - LOG_LEVEL=INFO

The volume mount contains a single file called pyhydroquebec.yaml.

timeout: 30
frequency: 10800
accounts:
- username: your@email.com
  password: password
  contracts:
    - id: 123456789

@ioio85
Copy link

ioio85 commented Jul 27, 2020

Thank you so much Luc. I have been looking for some instructions for months. This really helped !

For anyone who is interested these are additional details how I did it:

  • create the file docker-compose.yml (with the first file content of Luc message)
  • Run this command in the folder where you save the file: docker-compose up -d
  • Create the other file (with the second content) and save it as pyhydroquebec.yaml
  • Copy this file to the container sudo docker cp ./pyhydroquebec.yaml pyhydroquebec:/etc/pyhydroquebec/
  • restart the container sudo docker restart pyhydroquebec
  • check if everything is ok sudo docker logs pyhydroquebec

Cheers

@roger1233
Copy link

Merci @lucboudreau

I was not able to go the docker route however, since I use a raspberry pi, and I can't find an arm version of the docker. Is there one?

In the meantime, I used @p0pp3t0n solution (which is deprecated from ha, I know) and it works. Thanks!

@roger1233
Copy link

roger1233 commented Sep 4, 2020

I'm using hassio so i'm not sure how to get it to work
Iget Platform error sensor.hydroquebec - No module named 'pyhydroquebec'
most likely because I can't run the pip command... anyone know where I should put it?

Got the same error. It seems HA will run the pip command after restart and will get the module, because of the mention of it in manifest.json... So just ignore and restart. It worked for me. Hope this helps.

@betelz
Copy link

betelz commented Sep 8, 2020

Thanks @lucboudreau.

I had never used Docker before. I read and learned. It's always fun to learn new things.

Here's what I've done for those who, like me, are wondering how to use Docker-Compose.

pyhydroquebec:
  container_name: pyhydroquebec
  image: registry.gitlab.com/ttblt-hass/pyhydroquebec/mqtt:master
  volumes:
  - /home/user/pyhydroquebec:/etc/pyhydroquebec
  restart: unless-stopped
  environment:
    - MQTT_USERNAME=user
    - MQTT_PASSWORD=password
    - MQTT_HOST=X.X.X.X
    - MQTT_PORT=1883
    - ROOT_TOPIC=homeassistant
    - MQTT_NAME=pyhydroquebec
    - LOG_LEVEL=INFO

You will have to replace in the volume section the text before the colon by the directory where will be the file pyhydroquebec.yaml ex: /home/user/pyhydroquebec:/etc/pyhydroquebec becomes for me /home/monusager/pyhydroquebec:/etc/pyhydroquebec
Obviously, change the environment values (MQTT_USERNAME, MQTT_PASSWORD, MQTT_HOST) to the values that are yours:

  • Create the configuration file (nano pyhydroquebec.yaml) borrowed from @lucboudreau
timeout: 30
frequency: 10800
accounts:
- username: your@email.com
  password: password
  contracts:
    - id: 123456789

Enter your credential and contract number for the Hydro-Québec site in the file.

  • Start Docker Composer (docker-compose up) Important! Run the command from the directory where the docker-compose.yml file is located.
    There you go! In home assistant I now have a "hydroquebec" device.

To automate the start-up of my container I have created a systemctl service
ref: https://stackoverflow.com/questions/43671482/how-to-run-docker-compose-up-d-at-system-start-up/45193532
To control the service:
systemctl start docker-compose-app.service
systemctl status docker-compose-app.service
systemctl stop docker-compose-app.service

@mshamash
Copy link

Thanks for posting this @lucboudreau and @betelz . I managed to get Home Assistant connected with pyhydroquebec docker via MQTT. Any advice on how I can now use the hydroquebec_123456789_yesterday_total_consumption in the Energy tab to monitor grid consumption daily? Or at least get some sort of graph/statistics, since this value updates once a day? Thanks in advance.

@betelz
Copy link

betelz commented Aug 21, 2021

I use mini-graph-card (Installed from HACS).

image

Here is the Lovelace YAML I use for this card.

aggregate_func: max
entities:
  - color: yellow
    entity: sensor.hydroquebec_123456789_yesterday_total_consumption
    name: Energie Maison
group_by: date
hour24: true
hours_to_show: 360
name: Energie Maison (hier)
show:
  graph: bar
type: custom:mini-graph-card

I didn't try the Energy Tab yet.

@mshamash
Copy link

Thank you @betelz that worked perfectly!

@arsenicks
Copy link

I think this may interest some of you guy's: #64

TL;DR I've created a hass add-on for pyhydroquebec, surely far from perfect but I got everything working for most arch and looking for feedback, so feel free to test and report issue!

https://github.com/arsenicks/pyhydroquebec-hass-addons

@petebdeblois
Copy link

@arsenicks at this point, I don't think this repo is maintained. Do you have plan to maybe fork and maintained an image of your own?
THere is some interesting PR here that are not reviewed/merged. Like the Hourly data.

@arsenicks
Copy link

@petebdeblois Yeah that's what I realised in the last few days. According to my research @titilambert hasn't posted since january 24 here but he's still active on Github as far as I can see(his last PR nov. 5 on other projects).

So to answer your question I have no plan to fork and maintain this repo, my contribution was aiming at using pyhydroquebec and create an easy to use add-on for HASS.

I would be happy to step in if the owner of this repos clearly state he doesn't want to maintain it anymore, but unfortunately I don't think I have the python skills required to maintain and review code.. seeing all those PR lined up, I'm pretty sure there's skilled people here that could step in. I would be happy to help for everything I can if needed..

But again, I think we really need to hear from @titilambert at this time.. One of his last post state he's been off a little bit waiting for HQ to send him test user and password for unit tests. My guess, he's probably dead waiting for HQ according to my experience with them..

TL;DR No plan Like that, will still work on the hass add-on, maybe a custom integration available in HACS in near future. We need to know the state of this project before anything can be done, otherwise we'll fragment the community and it will be more confusing than anything.

@Normand9999
Copy link

Great add-on arsenicks. I was able to get yesterday total consumption and yesterday average temperature using a custom component for the last year (not through MQTT) but with your add-on I have much more entities which is great. Thanks you for sharing the information.

@mvonh
Copy link

mvonh commented Dec 19, 2021

@arsenicks Hi nice work. I installed and run it. I missed the info about the 2 config files, but once I read it again I got it working. Anyway to get it to play nice with the new energy tracking functionality in Home assistant?

https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics

@arsenicks
Copy link

@arsenicks Hi nice work. I installed and run it. I missed the info about the 2 config files, but once I read it again I got it working. Anyway to get it to play nice with the new energy tracking functionality in Home assistant?

https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics

Yes, take a look at this comment: arsenicks/pyhydroquebec-hass-addons#9 (comment)

I haven't try because I got my Hilo setup so I don't use the add-on anymore.. So if anyone in the community want to step up fork and maintain it that would be great I could give permission on my repo too. But I know myself, if I don't use it anymore I probably won't put too much effort into that... There's only 24h in a day after all!

@mvonh
Copy link

mvonh commented Dec 24, 2021

Ok cool, sorry I missed this. Thanks again, have fun with Hilo--how do you like it?

@arsenicks
Copy link

It's been great so far. I don't like the light dimmer tho, but the thermostat are great.. The integration into HA has to be rebuilt from scratch following an update on Hilo side the day I got my installation done.. So far the new integration work great with fre bugs but it's fun!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests