teslamotors / vehicle-command

Apache License 2.0
425 stars 92 forks source link

BLE protocol: Action HvacTemperatureAdjustmentAction ignores set properties values #183

Closed hleao closed 7 months ago

hleao commented 7 months ago

When using the ble protocol to send the action HvacTemperatureAdjustmentAction, only values for properties driver_temp_celsius and passenger_temp_celsius are being considered and all others are ignored.

For example, sending a message with values only for delta_celsius = 1 and hvac_temperature_zone = 2 (TEMP_ZONE_FRONT_LEFT) does not work. The car ignores the values for those 2 properties and, since driver_temp_celsius and passenger_temp_celsius are not set, it sets both temperatures to 'LO'.

That makes it is not possible to increase or decrease the temperature, with a given delta, using ble.

hleao commented 7 months ago

Here is an example, a slightly modified version of Vehicle.ChangeClimateTemp(...) from what we have in climate.go. Executing this action results in temperature for both driver and passenger being set to 'LO'.

func (v *Vehicle) ChangeClimateTemp(ctx context.Context, driverCelsius float32, passengerCelsius float32) error {
  var zones []*carserver.HvacTemperatureAdjustmentAction_HvacTemperatureZone

  var zone *carserver.HvacTemperatureAdjustmentAction_HvacTemperatureZone =  new(carserver.HvacTemperatureAdjustmentAction_HvacTemperatureZone)
  zone.Type = &carserver.HvacTemperatureAdjustmentAction_HvacTemperatureZone_TEMP_ZONE_FRONT_LEFT{}

  zones = append(zones, zone)

  return v.executeCarServerAction(ctx,
    &carserver.Action_VehicleAction{
      VehicleAction: &carserver.VehicleAction{
        VehicleActionMsg: &carserver.VehicleAction_HvacTemperatureAdjustmentAction{
          HvacTemperatureAdjustmentAction: &carserver.HvacTemperatureAdjustmentAction{
            DeltaCelsius: 1, // <- Added but no effect 
            HvacTemperatureZone: zones, // <- Added but no effect
            Level: &carserver.HvacTemperatureAdjustmentAction_Temperature{
              Type: &carserver.HvacTemperatureAdjustmentAction_Temperature_TEMP_MAX{},
            },
          },
        },
      },
    })
}
sheng168 commented 7 months ago

I wonder what level of feature parity BLE is suppose to have vs REST transport?

sethterashima commented 7 months ago

This doesn't appear to be a BLE issue. The API defined in climate.go doesn't support those fields because they are currently not used by the car.

@sheng168 In general their should be parity between BLE and HTTP. The commands end up in the same place. There are a small number of exceptions related to security (e.g., fleet manager keys cannot authorize commands over BLE) or technical constraints (e.g., vehicle wake behavior).