Ankündigung

Einklappen
Keine Ankündigung bisher.

Vistapool webabfrage

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    [HS-Logik] Vistapool webabfrage

    I'm looking for some help since my Python skills are close to zero.
    I, with hopefully some help on this forum, would like to build a logic module to read the values of my pool controller. I can build a basic logic module but I have no knowledge of integrating Python scripting into the module.
    Login into the vista pool website requires user/password which isn't easy to do into the address
    I've found a python script in another forum that is able to log in and parse the data.
    https://community.home-assistant.io/...gration/128695
    Basically this is the script written by "Uspino". Thank you for posting.

    Can someone integrate this into a logic module or give me some guidance?

    #!/usr/bin/env python
    # coding: utf-8
    # In[ ]: import requests

    # Fill in your details here to be posted to the login form.

    payload = { 'user': ‘your@email.address’, 'pass': ‘yourpassword’, 'remember_password': '0', 'entrar': 'Enter' }

    # Use 'with' to ensure the session context is closed after use.

    with requests.Session() as s:
    p = s.post('http://vistapool.es/en/login/login', data=payload)

    # An authorised request.

    r = s.get('http://vistapool.es/en/pool/getmainvalues?id=1234’) print(r.text)


    The above script he saved as vista.py .

    He then created a command-line to execute the script every x time.

    This is the script

    - platform: command_line
    name: Pool
    scan_interval: 600
    command_timeout: 30
    json_attributes:
    - filtration_stat
    - PH
    - RX

    command: "python3 /config/www/vistapool/vista.py"
    value_template: '{{ value_json.temp | replace("º","") | replace("C","") }}'
    unit_of_measurement: '°C'

    - platform: template
    sensors:
    phlevel:
    friendly_name: pH Level
    value_template: '{{ states.sensor.pool.attributes.PH }}'

    filtrationstatus:
    friendly_name: Filtration Status
    value_template: '{{ states.sensor.pool.attributes.filtration_stat }}'

    rxlevel:
    friendly_name: RX Level
    value_template: '{{ states.sensor.pool.attributes.RX }}'

    #2
    I've been reading through the HSL2.0 documentation and trying to make the module but with limited Python skills it's a steep learning curve.
    I'm stuck with getting the simulator to work.
    python simulator.pyc "my project" "example project 01" gives me these errors which i'm unable to solve with my skills.

    Vistapool14444:5: SyntaxWarning: name 'hsl20_4_debug_page' is used prior to global declaration

    Vistapool14444:99: SyntaxWarning: name 'hsl20_4' is used prior to global declaration

    Vistapool14444:463: SyntaxWarning: name 'Vistapool14444' is used prior to global declaration

    Traceback (most recent call last):

    File "C:\!svn\hsl\branches\release_1-9\bubu\HSL20_Framework\simulator.py", line 954, in <module>

    File "C:\!svn\hsl\branches\release_1-9\bubu\HSL20_Framework\simulator.py", line 822, in start

    File "C:\!svn\hsl\branches\release_1-9\bubu\HSL20_Framework\simulator.py", line 374, in start

    File "C:\!svn\hsl\branches\release_1-9\bubu\HSL20_Framework\simulator.py", line 426, in _init_logic

    File "<string>", line 1, in <module>

    File "Vistapool14444", line 501, in <module>

    NameError: name 'MC' is not defined


    This is my python file. It's basic but I first want to get the data imported before I can start parsing it. Any ideas on the errors?

    # coding: UTF-8
    ##!!!!############################################ ################################################## ####
    #### Own written code can be placed above this commentblock . Do not change or delete commentblock! ####
    ################################################## ################################################## ####
    ##** Code created by generator - DO NOT CHANGE! **##

    class Vistapool14444(hsl20_4.BaseModule):

    def __init__(self, homeserver_context):
    hsl20_4.BaseModule.__init__(self, homeserver_context, "hsl20_4_Vistapool")
    self.FRAMEWORK = self._get_framework()
    self.LOGGER = self._get_logger(hsl20_4.LOGGING_NONE,())
    self.PIN_I_TRIGGER=1
    self.PIN_I_POOL_ID=2
    self.PIN_I_USERNAME=3
    self.PIN_I_PASSWORD=4
    self.PIN_O_OUTPUT=1
    self.PIN_O_TEMP=2
    self.PIN_O_LIGHTS_MODE=3
    self.PIN_O_LIGHTS_STATUS=4
    self.PIN_O_FILTRATION_STATUS=5
    self.PIN_O_FILTRATION_MODE=6
    self.PIN_O_FILTRATION_TIME_REMAINING=7
    self.PIN_O_PH_VALUE=8
    self.PIN_O_PH_ALARM=9
    self.PIN_O_PH_TYPE=10
    self.PIN_O_PH_HIGH_VALUE=11
    self.PIN_O_RX_VALUE=12
    self.PIN_O_RX_TARGET=13
    self.PIN_O_RX_STATUS=14
    self.PIN_O_RX_CURRENT=15
    self.PIN_O_RX_HYDRO=16
    self.PIN_O_CL=17
    self.PIN_O_CL1=18
    self.PIN_O_CL_STATUS_HYDRO=19
    self.PIN_O_CD=20
    self.PIN_O_CD1=21
    self.PIN_O_CD_STATUS=22
    self.FRAMEWORK._run_in_context_thread(self.on_init )

    ################################################## ################################################## ####
    #### Own written code can be placed after this commentblock . Do not change or delete commentblock! ####
    ################################################## #################################################! !!##

    def on_init(self, payload):
    self.payload = {'user': self.PIN_I_USERNAME, 'pass': self.PIN_I_PASSWORD, 'remember_password': '0', 'entrar': 'Enter'}

    def on_input_value(self, index, value):
    if index == self.PIN_I_TRIGGER:
    # Use 'with' to ensure the session context is closed after use.
    with requests.Session() as s:
    p = s.post('http://vistapool.es/en/login/login', self.payload)
    # An authorised request.
    r = s.get("http://vistapool.es/en/pool/getmainvalues?id=" + self.PIN_0_POOL_ID)
    print(r.text)






    Kommentar

    Lädt...
    X