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

Send state based on reported status, apply car prefix to car sensors, add some logging around new car sensors #3668

Merged
merged 4 commits into from
Jul 19, 2023

Conversation

dshokouhi
Copy link
Member

@dshokouhi dshokouhi commented Jul 17, 2023

Summary

  • Send state based on reported status so users know if a sensor is not implemented
  • Apply Car prefix to sensor names for consistency and easy identification.
  • Add some more logging for troubleshooting
  • Minor clean-up

image

Add some debug logging around car data as I am only seeing Car Name being pulled in, even after going for a drive increasing odometer and decreasing fuel.

Screenshots

Link to pull request in Documentation repository

Documentation: home-assistant/companion.home-assistant#

Any other notes

CC: @drosoCode in case you have any ideas on why some data is not retrieved.

@jpelgrom
Copy link
Member

Are the % and m in your screenshot at the end of the state debug info or another bug?

@dshokouhi
Copy link
Member Author

Are the % and m in your screenshot at the end of the state debug info or another bug?

unit of measurement which we arbitrarily apply to all sensors that have it :)

@drosoCode
Copy link
Contributor

Maybe your car/phone doesn't export these data ?
I only tested it with the desktop head unit (does it works for you ?), and it only worked using a samsung phone (my oneplus didn't send any data)
Is is working with this app (in Settings > Vehicle Data) ?

@dshokouhi
Copy link
Member Author

I don't have an ev car not sure the app will work? I wonder if there is a different status reported which I think the debug logs will show

@dshokouhi
Copy link
Member Author

Is is working with this app (in Settings > Vehicle Data) ?

Some data shows up yes, as expected though EV charging status and range remaining is not loading.

image

@drosoCode
Copy link
Contributor

1689627562
I tried with the DHU (can't test with my car this week) and the charge level still shows up when setting fuel value (even if it's not an EV). So the problem is probably that your android auto implementation is not aware of the car sensors (only the gps seems to be used on your screenshot).

@dshokouhi
Copy link
Member Author

dshokouhi commented Jul 18, 2023

Ok using the DHU here are the debug results after enabling the sensors and changing values, so looks like I am getting some data from here. Wonder what I see in the car. Before enabling the sensors in the DHU config I was seeing a status of unknown, then once enabled in the config file they got unimplemented status. Then once I provided a value the results are as below.

2023-07-18 11:35:49.900 18112-18112 CarSM                   io....stant.companion.android.debug  D  Received Energy level: [ battery percent: [value: null, timestamp: 667428331579795, Status: 2, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], fuel percent: [value: 50.0, timestamp: 667428331579795, Status: 1, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], energyIsLow: [value: null, timestamp: 667428331579795, Status: 2, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], range remaining: [value: null, timestamp: 667428331579795, Status: 2, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], distance display unit: [value: null, timestamp: 0, Status: 2, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], fuel volume display unit: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]]]
2023-07-18 11:36:40.942 24187-24187 CarSM                   io....stant.companion.android.debug  D  Received mileage: [ odometer: [value: 5000.0, timestamp: 667479386594509, Status: 1, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], distance display unit: [value: null, timestamp: 0, Status: 2, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]]]
2023-07-18 11:36:40.935 24187-24187 CarSM                   io....stant.companion.android.debug  D  Received status available: [ EV charge port open: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], EV charge port connected: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]]]

@dshokouhi dshokouhi changed the title Apply car prefix to car sensors, add some logging around new car sensors Send state based on reported status, apply car prefix to car sensors, add some logging around new car sensors Jul 19, 2023
@dshokouhi
Copy link
Member Author

latest update now updates the state based on the reported CarValue status as this is the only way to tell if something will work or not.

Copy link
Member

@jpelgrom jpelgrom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, too bad we can't determine status in advance.

Suggestion to make the code more concise: make carValueStatus return String? with CarValue.STATUS_SUCCESS -> null, so you can write the sensor state like this:

status ?: data.thing.value!!

@dshokouhi
Copy link
Member Author

Looks good, too bad we can't determine status in advance.

Suggestion to make the code more concise: make carValueStatus return String? with CarValue.STATUS_SUCCESS -> null, so you can write the sensor state like this:

status ?: data.thing.value!!

Thats a lot cleaner, will add that update now

@jpelgrom
Copy link
Member

To be safe you should probably still return unavailable when the status isn't listed in the when, the value only exists when status is success.

@JBassett JBassett merged commit d421b88 into home-assistant:master Jul 19, 2023
4 checks passed
@dshokouhi
Copy link
Member Author

yup my car does not support much of any sensors 😢

07-20 16:26:16.360  9481  9481 D CarSM   : Received status available: [ EV charge port open: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], EV charge port connected: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]]]
07-20 16:26:16.364  9481  9481 D CarSM   : Received model information: [ name: [value: Ascent, timestamp: 0, Status: 1, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], year: [value: 2023, timestamp: 0, Status: 1, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], manufacturer: [value: SUBARU, timestamp: 0, Status: 1, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]]]
07-20 16:26:16.372  9481  9481 D CarSM   : Received Energy level: [ battery percent: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], fuel percent: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], energyIsLow: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], range remaining: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], distance display unit: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], fuel volume display unit: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]]]
07-20 16:26:16.390  9481  9481 D CarSM   : Received mileage: [ odometer: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]], distance display unit: [value: null, timestamp: 0, Status: 0, CarZones: [[CarZone row value: CAR_ZONE_ROW_ALL, column value: CAR_ZONE_COLUMN_ALL]]]]

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

Successfully merging this pull request may close these issues.

None yet

4 participants