From fe42b1101cd5885bb1d4209ee715118c40d075d5 Mon Sep 17 00:00:00 2001 From: Giorgio Ravera Date: Fri, 7 Jun 2019 09:33:04 +0200 Subject: [PATCH] Starting migration to new mercedes api --- binary_sensor/car.yaml | 91 ++++++++++++++++++++++++++++++-------- components/mercedesme.yaml | 6 ++- configuration.yaml | 3 +- customizations/car.yaml | 69 +++++++++++++++++++++-------- logger.yaml | 3 +- ui-lovelace.yaml | 23 +++++----- 6 files changed, 145 insertions(+), 50 deletions(-) diff --git a/binary_sensor/car.yaml b/binary_sensor/car.yaml index e26d2210..1fdc93d5 100644 --- a/binary_sensor/car.yaml +++ b/binary_sensor/car.yaml @@ -18,30 +18,85 @@ {% endif %} ###################################################################### -# Binary Sensor: Car Windows Lock +# Binary Sensor: Doors Closed ###################################################################### - platform: template sensors: - car_windows_lock: - friendly_name: Chiusura Finestrini + ff590mr_doors_closed: + friendly_name: Chiusura Porte device_class: lock entity_id: - - sensor.ff590mr_window_front_left - - sensor.ff590mr_window_front_right - - sensor.ff590mr_window_rear_left - - sensor.ff590mr_window_rear_right + - sensor.ff590mr_lock value_template: >- - {{ not (is_state('sensor.ff590mr_window_front_left', '2') - and is_state('sensor.ff590mr_window_front_right', '2') - and is_state('sensor.ff590mr_window_rear_left', '2') - and is_state('sensor.ff590mr_window_rear_right', '2') ) }} + {{ is_state_attr('sensor.ff590mr_lock', 'frontLeftDoorClosed', 'true') + and is_state_attr('sensor.ff590mr_lock', 'frontRightDoorClosed', 'true') + and is_state_attr('sensor.ff590mr_lock', 'rearLeftDoorClosed', 'true') + and is_state_attr('sensor.ff590mr_lock', 'rearRightDoorClosed', 'true') }} icon_template: >- - {% if is_state('sensor.ff590mr_window_front_left', '2') - and is_state('sensor.ff590mr_window_front_right', '2') - and is_state('sensor.ff590mr_window_rear_left', '2') - and is_state('sensor.ff590mr_window_rear_right', '2') %} - mdi:window-closed + {% if is_state_attr('sensor.ff590mr_lock', 'frontLeftDoorClosed', 'true') + and is_state_attr('sensor.ff590mr_lock', 'frontRightDoorClosed', 'true') + and is_state_attr('sensor.ff590mr_lock', 'rearLeftDoorClosed', 'true') + and is_state_attr('sensor.ff590mr_lock', 'rearRightDoorClosed', 'true') %} + mdi:car-door {% else %} - mdi:window-open - {% endif %} \ No newline at end of file + mdi:car-door + {% endif %} + +###################################################################### +# Binary Sensor: Decklid Status +###################################################################### + +- platform: template + sensors: + ff590mr_status_decklid: + friendly_name: Bagagliaio + device_class: opening + entity_id: sensor.ff590mr_lock + value_template: >- + {{ not is_state_attr('sensor.ff590mr_lock', 'trunkStateRollup', 'CLOSED_AND_LOCKED') }} + icon_template: >- + {% if is_state('sensor.ff590mr_lock', 'CLOSED_AND_LOCKED') %} + mdi:lock + {% else %} + mdi:lock-open + {% endif %} + +###################################################################### +# Binary Sensor: Warning Brake fluid +###################################################################### + +- platform: template + sensors: + ff590mr_warning_brakefluid: + friendly_name: Liquido freni + device_class: problem + entity_id: binary_sensor.ff590mr_engine_light_warning + value_template: >- + {{ is_state_attr('binary_sensor.ff590mr_engine_light_warning', 'warningbrakefluid', 'true') }} + +###################################################################### +# Binary Sensor: Warning washwater +###################################################################### + +- platform: template + sensors: + ff590mr_warning_washwater: + friendly_name: Liquido lavacristalli + device_class: problem + entity_id: binary_sensor.ff590mr_engine_light_warning + value_template: >- + {{ is_state_attr('binary_sensor.ff590mr_engine_light_warning', 'warningwashwater', 'true') }} + +###################################################################### +# Binary Sensor: Warning coolant level low +###################################################################### + +- platform: template + sensors: + ff590mr_warning_coolantlevellow: + friendly_name: Liquido raffreddamento + device_class: problem + entity_id: binary_sensor.ff590mr_engine_light_warning + value_template: >- + {{ is_state_attr('binary_sensor.ff590mr_engine_light_warning', 'warningcoolantlevellow', 'true') }} diff --git a/components/mercedesme.yaml b/components/mercedesme.yaml index dcb229c7..614ad85a 100644 --- a/components/mercedesme.yaml +++ b/components/mercedesme.yaml @@ -4,4 +4,8 @@ username: !secret mb_user password: !secret mb_password -scan_interval: 120 +pin: !secret mb_pin # need to open the lock, please use the Mercedes web or app to set-up the pin +country_code: IT # two digts country code +accept_lang: it_IT # four digits country code +save_car_details: false # save a json to the HA config directory with the features and states, please use this for debug only +#scan_interval: 120 diff --git a/configuration.yaml b/configuration.yaml index fb378320..6274e41d 100644 --- a/configuration.yaml +++ b/configuration.yaml @@ -149,7 +149,8 @@ maxcube: !include components/eq3max.yaml google_assistant: !include components/google_assistant.yaml # Mercedes Me -mbwebbeta: !include components/mercedesme.yaml +#mbwebbeta: !include components/mercedesme.yaml +mercedesmeapi: !include components/mercedesme.yaml # Weather weather: !include components/weather.yaml diff --git a/customizations/car.yaml b/customizations/car.yaml index 080366e1..c26e7478 100644 --- a/customizations/car.yaml +++ b/customizations/car.yaml @@ -2,23 +2,62 @@ # Mercedes Me ###################################################################### -# Sensori -binary_sensor.ff590mr_decklid_status: - friendly_name: Bagagliaio - device_class: opening -binary_sensor.ff590mr_warning_washwater: - friendly_name: Liquido lavacristalli - device_class: problem -binary_sensor.ff590mr_warning_brakefluid: - friendly_name: Liquido freni +# Binary Sensors +binary_sensor.ff590mr_engine_light_warning: + friendly_name: Allarme Generale device_class: problem -binary_sensor.ff590mr_parkbrake_status: + icon: mdi:hazard-lights + # warningbrakefluid, warningcoolantlevellow, warningwashwater +binary_sensor.ff590mr_park_brake_status: friendly_name: Freno a mano device_class: plug icon: mdi:car-brake-parking -binary_sensor.ff590mr_warning_engine_light: - friendly_name: Allarme Motore +binary_sensor.ff590mr_tire_warning: + friendly_name: Allarme Pneumatici device_class: problem + icon: mdi:car-tire-alert + # lastTirepressureTimestamp + # tireWarningRollup + # tireMarkerFrontLeft, tireMarkerRearLeft, tireMarkerRearRight + # tirepressureFrontLeft, tirepressureFrontRight, tirepressureRearLeft, tirepressureRearRight +binary_sensor.ff590mr_windows_closed: + friendly_name: Finestrini + device_class: opening + icon: mdi:window-closed + #icon: mdi:car-door + # windowstatusfrontleft, windowstatusfrontright, windowstatusrearleft, windowstatusrearright + +# Lock +lock.ff590mr_lock: + friendly_name: Blocco Sblocco + icon: mdi:lock-open + +# Sensors +sensor.ff590mr_fuel_level: + friendly_name: Livello Carburante + icon: mdi:gas-station +sensor.ff590mr_lock: + friendly_name: Veicolo + icon: mdi:lock-open +# doorsClosed +# frontLeftDoorLocked, frontLeftDoorClosed, doorStateFrontLeft +# frontRightDoorLocked, frontRightDoorClosed, doorStateFrontRight +# rearLeftDoorLocked, rearLeftDoorClosed, doorStateRearLeft +# rearRightDoorLocked, rearRightDoorClosed, doorStateRearRight +# trunkStateRollup +sensor.ff590mr_odometer_2: + friendly_name: Km Percorsi + icon: mdi:road-variant +# liquidconsumptionreset, liquidconsumptionstart, liquidRangeSkipIndication +# tanklevelpercent, tankReserveLamp +# serviceintervaldays +# distanceReset, distanceStart + + + + + + # Pressione gomme sensor.ff590mr_tire_pressure_front_left: @@ -89,12 +128,6 @@ sensor.ff590mr_licenseplate: # friendly_name: #sensor.ff590mr_liquid_consumption_start: # friendly_name: -sensor.ff590mr_odometer: - friendly_name: Km Percorsi - icon: mdi:road-variant -sensor.ff590mr_tank_level: - friendly_name: Livello Carburante - icon: mdi:gas-station sensor.ff590mr_distance_since_reset: friendly_name: Distanza dal reset icon: mdi:road-variant diff --git a/logger.yaml b/logger.yaml index 7a372315..03146ff0 100644 --- a/logger.yaml +++ b/logger.yaml @@ -8,5 +8,4 @@ logs: homeassistant.components.automation: info homeassistant.components.device_tracker: warn homeassistant.components.input_text: info - custom_components.mbwebbeta: warn - mbwebapppy.controller: warn + custom_components.mercedesmeapi: warn diff --git a/ui-lovelace.yaml b/ui-lovelace.yaml index 18a2781f..2f57a4fa 100644 --- a/ui-lovelace.yaml +++ b/ui-lovelace.yaml @@ -370,11 +370,14 @@ views: badges: - device_tracker.wdd1760081v167576 - sensor.ff590mr_odometer - - sensor.ff590mr_tank_level - - binary_sensor.car_doors_lock - - binary_sensor.car_windows_lock - - binary_sensor.ff590mr_parkbrake_status - - binary_sensor.ff590mr_decklid_status + - sensor.ff590mr_fuel_level +# - binary_sensor.ff590mr_park_brake_status +# - binary_sensor.ff590mr_status_decklid + - binary_sensor.ff590mr_engine_light_warning + - binary_sensor.ff590mr_tire_warning + - binary_sensor.ff590mr_doors_closed + - binary_sensor.ff590mr_windows_closed + - lock.ff590mr_lock cards: #- type: gauge # title: "Livello Carburante" @@ -389,11 +392,11 @@ views: title: "Mercedes A200d: Sensori" show_header_toggle: false entities: - - binary_sensor.ff590mr_parkbrake_status - - binary_sensor.ff590mr_decklid_status - - binary_sensor.ff590mr_warning_washwater + - binary_sensor.ff590mr_park_brake_status + - binary_sensor.ff590mr_status_decklid - binary_sensor.ff590mr_warning_brakefluid - - binary_sensor.ff590mr_warning_engine_light + - binary_sensor.ff590mr_warning_washwater + - binary_sensor.ff590mr_warning_coolantlevellow #- device_tracker.wdd1760081v167576 - type: entities @@ -445,7 +448,7 @@ views: - sensor.ff590mr_licenseplate - sensor.ff590mr_liquid_consumption_reset - sensor.ff590mr_liquid_consumption_start - #- sensor.ff590mr_odometer + - sensor.ff590mr_odometer_2 #- sensor.ff590mr_liquid_range #- sensor.ff590mr_electric_distance_since_start #- sensor.ff590mr_tank_level -- 2.47.3