zaknye / xcel_itron2mqtt

Broadcast your Xcel smart meter to MQTT
Apache License 2.0
61 stars 19 forks source link

Can't start service due to errors #35

Closed ryanpatrickmckenna closed 4 months ago

ryanpatrickmckenna commented 4 months ago

Hi there,

Thank you so much for making this, you're amazing.

I am running your code via the Home Assistant add-on hassio-xcel-itron-mqtt that @wingrunr21 made from your repo. I've connected my smart meter, got a static IP for it, I can pull data from the MEC app, got the LFDI and registered it but when I try to run the service in HA it errors out and stops.

Here's the logs:

-----------------------------------------------------------
 Add-on: Xcel iTron MQTT
 Bridge from Xcel iTron smart meters to MQTT
-----------------------------------------------------------
 Add-on version: 1.2.1
 You are running the latest version of this add-on.
 System: Home Assistant OS 12.4  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2024.6.4
 Home Assistant Supervisor: 2024.06.2
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service init-xcel-itron-mqtt: starting
[22:31:06] INFO: Initializing Xcel iTron2MQTT
[22:31:06] INFO: LDFI missing. Reading from certs
[22:31:07] INFO: LDFI: B4DF8B91F2DB398CD278F66FA14B384C89DEAC6F

s6-rc: info: service init-xcel-itron-mqtt successfully started
s6-rc: info: service xcel-itron-mqtt: starting
s6-rc: info: service xcel-itron-mqtt successfully started
s6-rc: info: service legacy-services: starting
[22:31:07] INFO: Starting Xcel iTron2MQTT
s6-rc: info: service legacy-services successfully started
[22:31:07] ERROR: Got unexpected response from the API: Service not enabled
Traceback (most recent call last):
  File "/opt/xcel_itron2mqtt/main.py", line 83, in <module>
    meter = xcelMeter(INTEGRATION_NAME, ip_address, port_num, creds)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/xcel_itron2mqtt/xcelMeter.py", line 58, in __init__
    self.mqtt_client = self.setup_mqtt(self.mqtt_server_address, self.mqtt_port)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/xcel_itron2mqtt/xcelMeter.py", line 197, in setup_mqtt
    client.connect(mqtt_server_address, mqtt_port)
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 912, in connect
    self.connect_async(host, port, keepalive,
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 978, in connect_async
    raise ValueError('Invalid host.')
ValueError: Invalid host.
[22:31:10] INFO: Service Xcel iTron2MQTe exited with code 1 (by signal 0)
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service xcel-itron-mqtt: stopping
s6-rc: info: service xcel-itron-mqtt successfully stopped
s6-rc: info: service init-xcel-itron-mqtt: stopping
s6-rc: info: service init-xcel-itron-mqtt successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service base-addon-log-level: stopping
s6-rc: info: service base-addon-log-level successfully stopped
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service base-addon-banner: stopping
s6-rc: info: service base-addon-banner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

There's some Python errors in the middle there. I'm only a beginner Python dev, I looked at your code and tried to figure out what's going on but couldn't. If this is an issue with the add-on let me know and I'll post an issue in that repo instead.

Thanks!

wingrunr21 commented 4 months ago

How are you running MQTT? I only support Home Assistant's MQTT service discovery right now so if that doesn't work you'll see those kinds of MQTT errors.

ryanpatrickmckenna commented 4 months ago

How are you running MQTT? I only support Home Assistant's MQTT service discovery right now so if that doesn't work you'll see those kinds of MQTT errors.

I've actually done nothing to set up MQTT. I was under the assumption that it was built in. Is that not the case?

wingrunr21 commented 4 months ago

You’ll need to configure the MQTT integration and a broker for your Home Assistant install: https://www.home-assistant.io/integrations/mqtt/

Should be pretty quick though, especially if you use the Mosquitto broker addon

ryanpatrickmckenna commented 4 months ago

Alright that worked! Thanks very much!