BigThunderSR / homeassistant-addons-onstar2mqtt

OnStarJS wrapper for MQTT as a Home Assistant Add-on
Apache License 2.0
24 stars 3 forks source link

Last Polling Time #410

Closed BrettEBowman closed 6 months ago

BrettEBowman commented 7 months ago

I like the new polling status (and error message, if applicable). However, I'd really also like to know the date/time of that last poll. Am I missing some place else to find that? Or could it be added to the polling status MQTT topic?

BigThunderSR commented 7 months ago

I usually look at the last updated time of the specific sensor in HA for that. Let me see what I can do about publishing the timestamp to a MQTT topic.

BigThunderSR commented 7 months ago

@BrettEBowman, change implemented in v1.12.4 and should provide what you are looking for: https://github.com/BigThunderSR/homeassistant-addons-onstar2mqtt/blob/main/onstar2mqtt-bigthundersr-vehicle1/DOCS.md#mqtt-polling-status-success-timestamp-monitor

Please confirm. Thanks.

BigThunderSR commented 7 months ago

@BrettEBowman, have you been able to try it out?

BrettEBowman commented 7 months ago

@BrettEBowman, have you been able to try it out?

I don't get a homeassistant/onstar2mqtt/... set of topics in my MQTT server. However, based upon your original suggestion, here's what I added to my config.yaml to get the time of the last error:

    - name: "Bolt OnStar Last Polling Status Timestamp"
      unique_id: bolt_onstar_last_polling_status_timestamp
      state_topic: "homeassistant/<VIN>/polling_status/state"
      value_template: "{{ as_timestamp(strptime(value_json.error.response.headers.date.replace(' GMT','+0000'), '%a, %d %b %Y %H:%M:%S%z')) | timestamp_local }}"  
      icon: mdi:calendar-clock
      device_class: timestamp
BigThunderSR commented 7 months ago

Please see the latest update in the link I provided for the current syntax and also use the latest version of the program I released yesterday. The old version of syntax that you are using is no longer valid in the latest version. Thanks.

BrettEBowman commented 7 months ago

Please see the latest update in the link I provided for the current syntax and also use the latest version of the program I released yesterday. The old version of syntax that you are using is no longer valid in the latest version. Thanks.

I'm running v 1.13.1. I tried changing my MQTT sensor to the latest suggested definition, but it remains Undefined in HA. I presume that is because I do not have a MQTT topic of "homeassistant/onstar2mqtt/vehicle1/polling/state" . As I stated in the last message, I don't have an "onstar2mqtt" tree under homeassistant in MQTT.

BigThunderSR commented 7 months ago

Please share your config so that I can try to help troubleshoot. It's working fine for me, so it definitely works.

BrettEBowman commented 7 months ago

Here's my config (with the VIN and username masked):

info: OnStar Config: {"onstarConfig":{"allowCommands":true,"checkRequestStatus":true,"deviceId":"befa0b8b-cd69-4e36-b6ae-8a9683c1ba69","onStarPin":"####","password":"********","refreshInterval":18000000,"requestPollingIntervalSeconds":6,"requestPollingTimeoutSeconds":90,"username":"*******","vin":"*****"},"timestamp":"2024-03-24 20:40:31"}
info: MQTT Config: {"mqttConfig":{"host":"192.168.143.16","namePrefix":"","password":"********","pollingStatusTopic":"","port":1883,"prefix":"homeassistant","rejectUnauthorized":true,"tls":false,"username":"mqtt-user"},"timestamp":"2024-03-24 20:40:31"}
BigThunderSR commented 7 months ago

I need to see the full YAML config of the add-on in Home Assistant. You can sanitize the user/pass/PIN/VIN etc.

BrettEBowman commented 7 months ago
LOG_LEVEL: info
VEHICLE_NAME: Brett's Bolt
ONSTAR_DEVICEID: befa0b8b-cd69-4e36-b6ae-8a9683c****
ONSTAR_VIN: ******
ONSTAR_USERNAME: ******
ONSTAR_PASSWORD: *****
ONSTAR_PIN: "####"
ONSTAR_URL: https://api.gm.com
ONSTAR_REFRESH: 18000000
ONSTAR_POLL_INTERVAL: 6
ONSTAR_POLL_TIMEOUT: 90
MQTT_HOST: 192.168.143.16
MQTT_USERNAME: ****
MQTT_PASSWORD: ****
MQTT_PORT: 1883
MQTT_PREFIX: homeassistant
MQTT_ONSTAR_POLLING_STATUS_TOPIC: ""
MQTT_TLS: false
MQTT_REJECT_UNAUTHORIZED: true
MQTT_CA_FILE: ""
MQTT_CERT_FILE: ""
MQTT_KEY_FILE: ""
BigThunderSR commented 7 months ago

I should have clarified in the example that the state topic depends on any given setup. If you don't provide a polling status topic, it defaults to:

homeassistant/VIN/polling_status

I'll update the example tomorrow.

BigThunderSR commented 7 months ago

@BrettEBowman, I have updated the following:

Hope things are clearer now. Please confirm if things are working after following the latest instructions.

BigThunderSR commented 6 months ago

@BrettEBowman, checking back on this. Thanks.

BigThunderSR commented 6 months ago

Closing due to no response. Please reopen if needed.