G-Two / homeassistant-subaru

Subaru STARLINK custom component for Home Assistant.
Apache License 2.0
54 stars 6 forks source link

Odd data behavior #119

Open wz2b opened 2 months ago

wz2b commented 2 months ago

I upgraded from the version of this integration that comes with home assistant to the latest github and there are two things going haywire:

Update: the odometer change is because it's now showing kilometers rather than miles. I'm not where where it got the notion it should do this.

The tire pressure I haven't figured out but "show raw" returns this:

                            'tirePressureFrontLeftPsi': '39.99',
                            'tirePressureFrontRight': None,
                            'tirePressureFrontRightPsi': '39',
                            'tirePressureRearLeft': None,
                            'tirePressureRearLeftPsi': '38',
                            'tirePressureRearRight': None,
                            'tirePressureRearRightPsi': '37',

and "show all" returns this:

                    'TYRE_PRESSURE_FRONT_LEFT': 40.0,
                    'TYRE_PRESSURE_FRONT_RIGHT': 39.0,
                    'TYRE_PRESSURE_REAR_LEFT': 38.0,
                    'TYRE_PRESSURE_REAR_RIGHT': 37.0,

so I think the library is right, and the home assistant end is somehow goofed ...

image

G-Two commented 2 months ago

Yeah it seems like HA is using all metric values for you (2757 hPa is about 39.9 psi) but displaying imperial unit names. I haven't received any other reports of this issue. Which version of HA are you using? Can you attach your HA generated device diagnostics output here?

wz2b commented 2 months ago

Core 2024.2.5 UI 20240207.1 I enabled debug logging, it will be a while before the car talks

On Sun, May 5, 2024 at 8:04 PM G-Two @.***> wrote:

Yeah it seems like HA is using all metric values for you (2757 hPa is about 39.9 psi) but displaying imperial unit names. I haven't received any other reports of this issue. Which version of HA are you using? Can you attach your HA generated device diagnostics output here?

— Reply to this email directly, view it on GitHub https://github.com/G-Two/homeassistant-subaru/issues/119#issuecomment-2095006851, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALTMOOOGROJY2GRASSACZDZA3CIXAVCNFSM6AAAAABHG5J24OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJVGAYDMOBVGE . You are receiving this because you authored the thread.Message ID: @.***>

wz2b commented 2 months ago

Something really odd is going on here. I'll show you just an excerpt rather than the whole thing.

2024-05-05 21:25:39.676 DEBUG (MainThread) [custom_components.subaru]
Subaru data {'climate': [],

 'vehicle_status': {'AVG_FUEL_CONSUMPTION': 9.7,
                    'DISTANCE_TO_EMPTY_FUEL': 530,
                    'DOOR_BOOT_POSITION': 'CLOSED',
                    'DOOR_ENGINE_HOOD_POSITION': 'CLOSED',
                    'DOOR_FRONT_LEFT_POSITION': 'OPEN',
                    'DOOR_FRONT_RIGHT_POSITION': 'CLOSED',
                    'DOOR_REAR_LEFT_POSITION': 'CLOSED',
                    'DOOR_REAR_RIGHT_POSITION': 'CLOSED',
                    'HEADING': None,
                    'LAST_UPDATED_DATE': '2024-05-05T16:48:00.000+0000',
                    'ODOMETER': 913,
                    'REMAINING_FUEL_PERCENT': '97',
                    'TIMESTAMP': datetime.datetime(2024, 5, 5, 16, 48,
tzinfo=datetime.timezone.utc),
                    'TYRE_PRESSURE_FRONT_LEFT': 2620,
                    'TYRE_PRESSURE_FRONT_RIGHT': 2551,
                    'TYRE_PRESSURE_REAR_LEFT': 2482,
                    'TYRE_PRESSURE_REAR_RIGHT': 2413,
                    'VEHICLE_STATE_TYPE': 'IGNITION_OFF',
                    'WINDOW_FRONT_LEFT_STATUS': 'OPEN',
                    'WINDOW_FRONT_RIGHT_STATUS': 'CLOSE',
                    'WINDOW_REAR_LEFT_STATUS': 'CLOSE',
                    'WINDOW_REAR_RIGHT_STATUS': 'CLOSE',
                    'WINDOW_SUNROOF_STATUS': 'CLOSE'}}

If I run subarulink vehicle_status I get the same results. Now, here's the strange part. I ran subarulink -i then show raw a few days ago and got this:

 'vehicleStatus': {'data': {'avgFuelConsumptionLitersPer100Kilometers': 9.6,
                            'avgFuelConsumptionMpg': 24.5,
                            'tirePressureFrontLeft': None,
                            'tirePressureFrontLeftPsi': '39.99',
                            'tirePressureFrontRight': None,
                            'tirePressureFrontRightPsi': '39',
                            'tirePressureRearLeft': None,
                            'tirePressureRearLeftPsi': '38',
                            'tirePressureRearRight': None,
                            'tirePressureRearRightPsi': '37',
                            'tyreStatusFrontLeft': 'UNKNOWN',
                            'tyreStatusFrontRight': 'UNKNOWN',
                            'tyreStatusRearLeft': 'UNKNOWN',
                            'tyreStatusRearRight': 'UNKNOWN',
                            'vehicleStateType': 'IGNITION_OFF',

                            'odometerValue': 567,
                            'odometerValueKilometers': 913,

I can't figure out the pattern here. "tire" vs "tyre" okay I guess.

***@***.***:~$ subarulink vehicle_status | grep -i odo
                    'ODOMETER': 567,

Sometimes I get:

                     'odometerUnit': 'MILES',
*```*

*```*
Orange> ***@***.***:~$ echo 'show raw' | subarulink -i | grep -i odometer
Odometer: 567 miles
                                   'odometer': 505,
                                   'odometerUnit': 'MILES',
                            'odometerValue': 567,
                            'odometerValueKilometers': 913,

the first two are in 'condition' and the second two are in 'vehicleStatus' ...

On Sun, May 5, 2024 at 9:21 PM Christopher Piggott @.***> wrote:

Core 2024.2.5 UI 20240207.1 I enabled debug logging, it will be a while before the car talks

On Sun, May 5, 2024 at 8:04 PM G-Two @.***> wrote:

Yeah it seems like HA is using all metric values for you (2757 hPa is about 39.9 psi) but displaying imperial unit names. I haven't received any other reports of this issue. Which version of HA are you using? Can you attach your HA generated device diagnostics output here?

— Reply to this email directly, view it on GitHub https://github.com/G-Two/homeassistant-subaru/issues/119#issuecomment-2095006851, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALTMOOOGROJY2GRASSACZDZA3CIXAVCNFSM6AAAAABHG5J24OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJVGAYDMOBVGE . You are receiving this because you authored the thread.Message ID: @.***>

G-Two commented 2 months ago

The HA diagnostics output feature would be more helpful for me to trace down the issue since it will show me a single snapshot of the current HA state and the associated JSON dump of the raw mysubaru.com API data (used to create the HA state) in a single file.

image

vehicleStatus is the raw JSON provided by the mysubaru.com API. The 'tyre' vs 'tire' naming is on them. They've changed their field names/casing over the years, so I try to keep things consistently named in vehicle_status (which contains the data after it has been processed by subarulink).

vehicle_status is provided by the subarulink package and what is used by the home assistant integration to set the state for the various sensors. For subarulink>=0.7.10, it should only supply US customary unit values (i.e. HA will convert to metric, if configured). If vehicle_status is supplying metric unit values in your case, then I need to see the raw data to figure out if there is an API inconsistency coming from mysubaru.com

EDIT: Corrected to state subarulink>=0.7.10

wz2b commented 2 months ago

subaru-e8c7878473ca0b27d2edffd38f782e79-Orange-953c6067ab6078a765313226cc0a21fa.json

Got it. Thanks for pointing to the download link. Also thanks for having the foresight to have it automatically scrub identifying information from the file, kudos :)

G-Two commented 1 month ago

That's strange, it's behaving like an older release of subarulink (metric values for tire pressure, odometer, and fuel economy in vehicle_health). I wonder if something is getting mixed up with python package paths in your container.

Can you enable debug logging for the subaru custom component, and then restart the component and then check your logs. I'd like to see what it is reporting for the first log entry (which should be the version of subarulink actually being run).

Example:

2024-05-06 21:23:41.450 DEBUG (MainThread) [custom_components.subaru] Using subarulink 0.7.11
wz2b commented 1 month ago

Sure.

2024-05-07 08:33:15.586 DEBUG (MainThread) [custom_components.subaru] Using subarulink 0.7.11

Also, inside the container:

ha:/config$ pip list | grep -i subaru
subarulink                       0.7.11
G-Two commented 1 month ago

I'd like to try to duplicate the issue on my end. Can you point me to a guide (or show me) how you setup your home assistant container with a non-root user? This would also help me with #118