Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Supervisor Add-on #5

Closed
Minims opened this issue Oct 28, 2021 · 37 comments
Closed

[Feature Request] Supervisor Add-on #5

Minims opened this issue Oct 28, 2021 · 37 comments
Labels
enhancement New feature or request

Comments

@Minims
Copy link

Minims commented Oct 28, 2021

Hello,

Any supervisor add-on planned to easy integrate this script in HA Supervised or HassOs ?

@yukulehe
Copy link
Owner

Hi @Minims ,
Thanks for your request. Do you have any documentation on how to integrate HA ? I have to evaluate the complexity. I would also appreciate to see a xxx2mqtt repository which is implemented as HA add-on.

@Minims
Copy link
Author

Minims commented Oct 30, 2021

You can have a look at this https://developers.home-assistant.io/docs/add-ons/repository/

You can look at mine for somfy for example:

@yukulehe
Copy link
Owner

yukulehe commented Nov 3, 2021

Thanks. I'm not using Hass.io but Hass core, so I'm not sure I could test the implementation of an add-on. However, I could first redesign current mqtt topics and value formats to suit to Hass's mqtt autodiscovery.

@Minims
Copy link
Author

Minims commented Nov 5, 2021

You can look to the Enedis project too, they just release an add-on too : https://github.com/m4dm4rtig4n/enedisgateway2mqtt

@Minims
Copy link
Author

Minims commented Nov 5, 2021

currently using the python app without docker. I've made some change for now to make it work without env vars and MQTTS for test purpose

@yukulehe
Copy link
Owner

yukulehe commented Nov 8, 2021

Maybe you could create a pull requests to integrate your enhancement ?
I know the enedisgateway repo and yes I will try to retain some functionnalities (except influxdb).
I've a dev branch 0.4.

@yukulehe
Copy link
Owner

yukulehe commented Nov 15, 2021

In 0.4, I've enhanced the script to allow HA's discovery. It works on my config. I'll need beta testers.
Concerning hass.io addons, it will be implemented in 0.5. I need to find someone to host the add-ons (as done by enedisgateway2mqtt).

@alexbelgium
Copy link
Contributor

alexbelgium commented Nov 16, 2021

Hello, a proposal for addon is here : https://github.com/alexbelgium/hassio-addons/tree/master/gazpar2mqtt
It works by exporting as ENV variables all values defined in a config.yaml file. This allows it to be perfectly future-ready as any new variables can simply be added to the config.yaml. All feedback is welcome!

@yukulehe
Copy link
Owner

Thanks a lot Alex. I will have a look to it.

@Minims
Copy link
Author

Minims commented Nov 16, 2021

Hello, a proposal for addon is here : https://github.com/alexbelgium/hassio-addons/tree/master/gazpar2mqtt
It works by exporting as ENV variables all values defined in a config.yaml file. This allows it to be perfectly future-ready as any new variables can simply be added to the config.yaml. All feedback is welcome!

Thanks I I will give it a try

@Minims
Copy link
Author

Minims commented Nov 16, 2021

@alexbelgium seems having an issue for installing the add-on. I have a PI4 with HomeAssisant Supervised
Gazpar

@alexbelgium
Copy link
Contributor

alexbelgium commented Nov 16, 2021

That's because you have installed the 32 bits version of HA and only docker images on amd64 and arm64 exists... The owner of the docker image needs to publish armv7 versions to allow it to work

@yukulehe : do you think you could add armv7 images? Thanks!

@yukulehe
Copy link
Owner

yukulehe commented Nov 16, 2021

I've an issue with armv7 for building docker image.

@yukulehe
Copy link
Owner

The lmxl package used to get data from grdf website sucks on armv7. I could built the docker image after many tries, but now the ci/cd takes a long time and the image volume has increased from 167mb to 530mb :(

@yukulehe
Copy link
Owner

I've pushed v0.4.1 to Latest in docker. It should be compatible with arm v7.
image
@alexbelgium @Minims , you can try again.

@alexbelgium
Copy link
Contributor

Ok, the addon v0.4.1 with armv7 is pushed

@Minims
Copy link
Author

Minims commented Nov 17, 2021

I have still the incompatible error for no on 4.1

@Minims
Copy link
Author

Minims commented Nov 17, 2021

Seems ok now tring

@yukulehe
Copy link
Owner

Cool. Let me know if everything suits now in HA.

@Minims
Copy link
Author

Minims commented Nov 17, 2021

Seems having a variable issue in the add-on I think :

-----------------------------------------------------------
 Add-on: gazpar2mqtt
 fetch GRDF data and publish data to a mqtt broker
-----------------------------------------------------------
 Add-on version: 0.4.1
 You are running the latest version of this add-on.
 System: Raspbian GNU/Linux 10 (buster)  (armv7 / raspberrypi4)
 Home Assistant Core: 2021.11.3
 Home Assistant Supervisor: 2021.10.8
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
 https://github.com/alexbelgium/hassio-addons
-----------------------------------------------------------
scripts/99-run.sh: executing
Using config file found in /config/gazpar2mqtt/config.yaml
./scripts/99-run.sh: line 25: EXIT_CODE: unbound variable
scripts/99-run.sh: exiting 1

@alexbelgium
Copy link
Contributor

Thanks, I've pushed a v2

@yukulehe
Copy link
Owner

Question for you @alexbelgium , do you need to update your add-on config each time I will published a new release of gazpar2mqtt ? Or could you point towards Latest version of docker (or main branch of github) ?

@alexbelgium
Copy link
Contributor

It's automatic - I've got a script that runs every two days, checks if a new version is published, an aligns the config :-)

@yukulehe
Copy link
Owner

Enhancement deployed in v0.4.1

@Minims
Copy link
Author

Minims commented Nov 18, 2021

I cannot connect to Mqtt, I don't know why for now.
I have tried to run the script directly on my Debian, I have the same issue.
So it seems not related to the add-on.

@yukulehe
Copy link
Owner

@Minims , could you share log from the script and also your environment variables ?

@Minims
Copy link
Author

Minims commented Nov 18, 2021

Of course, can you log exception for debug like :

    except Exception as e:
        logging.error(e)
        logging.error("Unable to connect to Mqtt broker. Please check that broker is running, or check broker configuration.")
        sys.exit(1)

Here is the log

Using config file found in /config/gazpar2mqtt/config.yaml
Config file is a valid yaml
Symlink created
[17:04:18] INFO: Starting the app with the variables in /config/gazpar2mqtt
GRDF_USERNAME="********"
GRDF_PASSWORD="********"
SCHEDULE_TIME="14:30"
MQTT_HOST="192.168.1.10"
MQTT_TOPIC="gazpar2mqtt"
MQTT_CLIENTID="gazpar2mqtt"
MQTT_USERNAME="********"
MQTT_PASSWORD="********"
MQTT_RETAIN="false"
STANDALONE_MODE="false"
HASS_DISCOVERY="false"
HASS_PREFIX="homeassistant"
[17:04:18] INFO: Timezone set from Etc/UTC to Europe/Paris
 
[17:04:18] INFO: Starting the app
 
2021-11-18 17:04:19,315 Welcome to gazpar2mqtt
2021-11-18 17:04:19,315 -----------------------------------------------------------
2021-11-18 17:04:19,316 -----------------------------------------------------------
2021-11-18 17:04:19,320 -----------------------------------------------------------
2021-11-18 17:04:19,321 Program parameters
2021-11-18 17:04:19,321 -----------------------------------------------------------
2021-11-18 17:04:19,321 GRDF config : username = "********", password = ******
2021-11-18 17:04:19,321 MQTT broker config : host = "192.168.1.10", port = 1883, clientId = "gazpar2mqtt", qos = 1, topic = "gazpar2mqtt", retain = "false"
2021-11-18 17:04:19,321 Standlone mode : Enable = "false"
2021-11-18 17:04:19,322 Home Assistant discovery : Enable = "false", Topic prefix = "homeassistant"
2021-11-18 17:04:19,322 -----------------------------------------------------------
2021-11-18 17:04:19,322 Connexion to Mqtt broker
2021-11-18 17:04:19,322 -----------------------------------------------------------
2021-11-18 17:04:19,323 Connect to Mqtt broker...
2021-11-18 17:04:19,325 Unable to connect to Mqtt broker. Please check that broker is running, or check broker configuration.
[17:04:19] FATAL: The app has crashed. Are you sure you entered the correct config options?

@yukulehe
Copy link
Owner

I suppose that the host's IP is correct, also the port (default value 1883) ? Do your mqtt broker allow external connexions ?
By the way (no related) : if you put false to both Standalone and Hass discovery, you'll never get values published on mqtt.

@Minims
Copy link
Author

Minims commented Nov 18, 2021

I works from my Debian. so I think the issue on the add-on.
I don't any connection to the mqtt broker add-on as I see for Enedis Gateway.

@Minims
Copy link
Author

Minims commented Nov 18, 2021

I suppose that the host's IP is correct, also the port (default value 1883) ? Do your mqtt broker allow external connexions ?

Yes, host and port are OK.
External is OK, my Debian is external but I make MQTTS (because external)

i have added this for my test on Debian :

import ssl
...
        client.tls_set(cert_reqs=ssl.CERT_NONE)
        client.tls_insecure_set(True)

By the way (no related) : if you put false to both Standalone and Hass discovery, you'll never get values published on mqtt.

Ok, but I have not really understand the standalone mode.

@yukulehe
Copy link
Owner

yukulehe commented Nov 18, 2021

Few days ago, you said that you made some change to allow mqtts connexion. In my script I've never make this kind of change.
Maybe that's the problem ?
image

@yukulehe
Copy link
Owner

Sorry I dind't see the ssl addition that you made.
Maybe you could propose a pull request to integrate this change ?
Cause I'm newbie on ssl.

@yukulehe
Copy link
Owner

yukulehe commented Nov 18, 2021

The standalone mode is for those who wants to use this app independtly from third party tools (like home assistant).
Values are published on mqtt without any special formatting : one topic / one value (as done by a real device)
Home assistant discovery format is really nice but very specific : prefix topic for the type of sensor (binary sensor or sensor) / config topic vs state topic / payload with many attributes....

@Minims
Copy link
Author

Minims commented Nov 18, 2021

SSL is not the issue here. it's a second server I used to test your project. As the server is not at home. I use SSL. I can make a PR later when I will be able to make all thing working.

On Hass, i have a MQTT in plain without SSL. Just the default broker configuration with user/password. I don't understand why it fails.

@yukulehe
Copy link
Owner

yukulehe commented Nov 18, 2021

Ok, maybe the authentification (user/password) fails on my script. Let me check. I will also compare with enedis2mqtt, cause we have the same mqtt libraries.
But.. I guess you have also enable the authentification on your mqtts broker... and it works fine..

@Minims
Copy link
Author

Minims commented Nov 18, 2021

i will fork both gazpar2mqtt and the add-on to debug my case

@alexbelgium
Copy link
Contributor

Hi, I don't fully understand, what is the issue ?

@yukulehe yukulehe added the enhancement New feature or request label Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants