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

MQTT reconnect bug fix, config file bug fixes #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jlr2mqtt.cfg.sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ MQTT_KEEPALIVE = 60

[MISC]
# Enabling this will post Home Assistant compatible config jsons to the homeassistant/jlr2mqtt_<category> topic
# openHAB (and Home Assistant) should then be able to automatically discover the corresponding sensors
HOMEASSISTANT_DISCOVERY = True
# openHAB (and Home Assistant) should then be able to automatically discover the corresponding sensors (case sensitive "true")
HOMEASSISTANT_DISCOVERY = true

# An empty or undefined discovery sensors list will try to create discovery for ALL status items (which may be quite a lot).
# Otherwise, individual status items can be listed here. For location data, a single 'position' should be added.
# Comma separated.
DISCOVERY_SENSORS_LIST = "ev_charging_status, ev_state_of_charge, ev_charging_method, ev_minutes_to_fully_charged, ev_range_battery_miles,
DISCOVERY_SENSORS_LIST = "ev_charging_status, ev_state_of_charge, ev_charging_method, ev_minutes_to_fully_charged, ev_range_on_battery_miles,
door_is_all_doors_locked, ev_preconditioning_mode,
alerts_preconditioning_started, alerts_preconditioning_not_ok_soc, alerts_preconditioning_stopped,
position"
Expand Down
8 changes: 4 additions & 4 deletions jlr2mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ def initialise_mqtt_client(mqtt_client):
logger.info("Connecting to mqtt server %s" % MQTT_SERVER)
mqtt_client.connect(MQTT_SERVER, port=1883, keepalive=MQTT_KEEPALIVE, bind_address="")

logger.info("Subscribing to mqtt topic '%s' for inbound commands" % MQTT_SUB_TOPIC)
mqtt_client.subscribe(MQTT_SUB_TOPIC)

return mqtt_client

Expand All @@ -120,6 +118,8 @@ def mqtt_on_connect(client, userdata, flags, rc):
if rc == 0:
client.connected_flag = True #set flag
logger.info("MQTT connection established with broker")
logger.info("Subscribing to mqtt topic '%s' for inbound commands" % MQTT_SUB_TOPIC)
mqtt_client.subscribe(MQTT_SUB_TOPIC)
update_state_on_mqtt("online")
else:
logger.error("MQTT connection failed (code {})".format(rc))
Expand Down Expand Up @@ -424,8 +424,8 @@ def get_status(for_key=None):

if "position" in location:
publish_position(location)
if "longitude" in location["position"] and "latitude" in location["position"]:
get_and_publish_reverse_geocode(location["position"])
#if "longitude" in location["position"] and "latitude" in location["position"]:
# get_and_publish_reverse_geocode(location["position"])
logger.info("3/{} Location data published to mqtt".format(count))

timers = get_departure_timers(v)
Expand Down