Flodu31/HomeAssistant-PeugeotIntegration

Get doors state

FilipeOS opened this issue · 0 comments

Hello, I tried the bellow code to get if some door is open or all are closed but I always get all closed and binary_sensor seems to fire one when doors are closed. But at same time, gets when I don't use car:

PSA All Doors Closed turned on
11:25:04 - 7 minutes ago
PSA All Doors Closed turned on
11:22:08 - 10 minutes ago
PSA All Doors Closed turned on
10:27:04 - 1 hour ago
PSA All Doors Closed turned on
10:18:21 - 1 hour ago
PSA All Doors Closed turned on triggered by state of PSA changed to OK
09:14:01 - 2 hours ago
PSA All Doors Closed turned off triggered by state of PSA changed to OK
09:08:53 - 2 hours ago
PSA All Doors Closed turned on
08:54:59 - 3 hours ago
PSA All Doors Closed turned on
08:29:02 - 3 hours ago
PSA All Doors Closed turned on

binary_sensor:

      - name: PSA All Doors Closed
        unique_id: psa_all_doors_closed
        state: >-
          {% set doors = state_attr('sensor.psa', 'doors_state').opening %}
          {% set open_doors = doors | selectattr('state', 'equalto', 'Open') | list %}
          {{ open_doors | length == 0 }}
        icon: mdi:car-door
"doors_state": {"locked_state": null, "opening": [{"identifier": "Trunk", "state": "Closed"}, {"identifier": "Driver", "state": "Closed"}, {"identifier": "RearRight", "state": "Closed"}, {"identifier": "RearLeft", "state": "Closed"}, {"identifier": "Passenger", "state": "Closed"}, {"identifier": "RearWindow", "state": "Closed"}, {"identifier": "RoofWindow", "state": "Closed"}], "updated_at": null}
- type: custom:mushroom-template-card
        entity: binary_sensor.psa_all_doors_closed
        primary: Doors
        secondary: >-
          {% if is_state('binary_sensor.psa_all_doors_closed', 'on') %}Closed 
          {% else %}Open  {% endif %}
        icon: >-
          {% if is_state('binary_sensor.psa_all_doors_closed', 'on')
          %}mdi:car-door-lock {% else %}mdi:car-door-unlock {% endif %}
        icon_color: >-
          {% if is_state('binary_sensor.psa_all_doors_closed', 'on') %}#4CAF50 
          {% else %}#F44336 {% endif %}
        tap_action:
          action: more-info
        style: |
          ha-card {
            border: none;
          }
          .type-custom-mushroom-template-card {
            padding-top: 4px;
            padding-bottom: 0px;
          }

please advise