Skip to content

How to store cookies in a HA sensor #407

Description

@Joao-Sousa-71

Description:

This is not a bug or issue but within the documentation I was not able to find a way to store the cookies received after the authentication and store them in HA sensor to be used in some rest commands.
I'm using this component to managem my pellets stove and after the authentication two cookies are received: "XSRF-TOKEN" and "myceza_session".

This is the content of the page_response_cookies.txt file

<Cookies[<Cookie XSRF-TOKEN=eyJpdiI6IlNjYXVwZFJOR1Zlam13UDlZYW5wSnc9PSIsInZhbHVlIjoiSFdzN0V6QWdUbkxaU2txaXh5WWEreWo4c1YzczFTa0xneU9ZdFdzbjREUWYrK0tLNDl4bVp3clhsVkg5UE1YayIsIm1hYyI6ImEwYWY5ODJkMTgwNzE5ODI1NTIyYzFlNjZmOTBlMDM1MGFkYzAxMGUyYzJkODEzYzA1YjBjOWU0YmU0NTgzNGQifQ%3D%3D for myceza.it />, <Cookie myceza_session=eyJpdiI6Ild5bVlDS21qaFhkUVwvK3AxQ2h1RmtBPT0iLCJ2YWx1ZSI6IjZNSXlWckJrcFBXSVlueWZOZEx1ZTZpdVpieW8xd2RIVEVJR1djVVhvcDk5NEJ4TVRqenQrYjgzVUVMTmNkTE8iLCJtYWMiOiI5ZjA4MmM4MjdjZThlMGFkMDI1MGQ0MzViZDAxNmE0Njc1MjhiODc1OTUwNDYxY2FkM2RkYzNhYmQ4Mzg3NWVjIn0%3D for myceza.it />]>

What I need is to have this two cookies available in two HA sensora to be possible to manage the stove by using rest commands. With the latest version can this be done? And if not, I can create a feature request.

Version of the custom_component

7.1.2 (latest)

Multiscrape configuration

multiscrape:
  - name: solzaima ha integration  
    resource: 'https://myceza.it/en'
    scan_interval: 86400
    log_response: True 
    form_submit:
      submit_once: False
      resubmit_on_error: True
      resource: 'https://myceza.it/en/login'
      select: '#main > div > div.panel-body > form'
      input:
        username: myemail@mail.com
        password: 'mypassword'
    sensor:
      - unique_id: mycezadatatoken
        select: 'div#app-meta'
        name: Myceza Data Token
        attribute: 'data-token'
        value_template: '{{ value }}'
        on_error:
          log: error
      - unique_id: mycezacsrftoken
        select: 'head > meta:nth-child(3)'
        name: Myceza CSRF Token
        attribute: 'content'
        value_template: '{{ value }}'        
        on_error:
          log: error

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions