Giter VIP home page Giter VIP logo

hass-sutro's People

Contributors

alain-afernandez avatar dependabot[bot] avatar dexhub avatar jeffrapp avatar wonderslug avatar ydogandjiev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hass-sutro's Issues

voluptuous.error.SchemaError: unsupported schema data type 'Platform'

Version of the custom_component

0.0.8

Configuration

No Additional COnfiguration

Describe the bug

This error happens when clicking the COFIGURE button in an already configured entry in the Integration entry.

Debug log


2024-06-09 10:00:30.809 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 81, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 262, in post
    return await super().post(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 70, in wrapper
    return await method(view, request, data, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 77, in post
    return await self._post_impl(request, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 84, in _post_impl
    result = await self._flow_mgr.async_init(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 343, in async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 517, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sutro/config_flow.py", line 99, in async_step_init
    return await self.async_step_user()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sutro/config_flow.py", line 111, in async_step_user
    vol.Required(x, default=self.options.get(x, True)): bool
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Use login credentials in order to obtain the api token.

Is your feature request related to a problem? Please describe.

The mechanism to obtain the API token is kinda difficult with either the Charles proxy example, or for HA users that are not experienced on the command line for the curl call example.

Describe the solution you'd like

Changes could be made to the config flow to take in the Sutro credentials and use them to make the HTTP call equivalent to the following curl call

curl --header "Content-Type: application/json" --compressed --header "Connection: Keep-Alive" --user-agent "okhttp/3.12.1" --data-binary '{"operationName":null,"variables":{"email":"EMAIL","password":"PASSWORD","focusedInput":"","loading":false},"query":"mutation ($email: String!, $password: String!) {\n login(email: $email, password: $password) {\n user {\n firstName\n lastName\n email\n phone\n releaseGroup\n __typename\n }\n token\n __typename\n }\n}\n"}' https://api.mysutro.com/graphql

This would allow the Token thats returned from the call to be directly captured and used for the configuration of the integration without the HA user having to do anything else.

Describe alternatives you've considered

Keep Charles Proxy or curl call options.

Additional context
NA

Allow users to view and complete recommendations from within the integration

Is your feature request related to a problem? Please describe.
Not a problem, just requesting additional functionality.

Describe the solution you'd like
Provide a way for users to see recommendations and mark them as complete once they've used the chemicals. The latest recommendations can be viewed by adding a few lines to the me query:

        {
            me {
                id
                firstName
                device {
                    batteryLevel
                    serialNumber
                    temperature
                    cartridgeCharges
                    health
                    coreStatus
                    lidOpen
                    online
                    shouldTakeReadings
                    lastMessage
                    currentFirmwareVersion
                }
                hub {
                    online
                    chargerStatus
                    ssid
                    lastMessage
                }
                pool {
                       ####  New Stuff Below This Line ####
                        latestRecommendations {
                          conflictWarning
                          recommendations {
                            id
                            chemical {
                              behaviour
                              image
                              name
                              types
                              packageSize
                              packageSizeUnit
                              upc
                            }
                            completedAt
                            expiredAt
                            type
                            decision
                            explanation
                            treatment
                          }
                      }
                    ####  New Stuff Above This Line ####
                    latestReading {
                        alkalinity
                        bromine
                        chlorine
                        ph
                        readingTime
                    }
                }
            }
        }

Recommendations can be completed with this mutation:

mutation ($recommendationId: ID!, $completedAt: DateTime) {
  completeRecommendation(recommendationId: $recommendationId, completedAt: $completedAt) {
    success
    completedAt
  }
}

And these params:

{
	"recommendationId": "245043",
	"completedAt": "2021-03-05T00:32:40.000Z"
}

Describe alternatives you've considered
N/A

Additional context
Add any other context or screenshots about the feature request here.

Last Update (?) borked Sutro integration for me

I tried deleting and re-adding the integration.

No Devices or Entities display upon adding Integration. Upon trying to "Configure" I get following:

Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble

No other logs or details available.

HA 2024.5.0 deprecation warning

Detected that custom integration 'sutro' calls async_add_job, which is deprecated and will be removed in Home Assistant 2025.4; Please review https://developers.home-assistant.io/blog/2024/03/13/deprecate_add_run_job for replacement options at custom_components/sutro/__init__.py, line 54: hass.async_add_job(, please create a bug report at https://github.com/ydogandjiev/hass-sutro/issues

Error when trying to update sensors when device isn't testing

My replacement cartridge is late due to some shipping issues on Sutro's end, so my device has stopped testing.

I can manually reload the integration and get the latest temp, but the other sensors are failing because they're getting back null.

I'd like to at least keep the temp going in these cases. Can some safety null checks be put in place to allow things to update when others are having issues?

Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:600
integration: Sensor (documentation, issues)
First occurred: June 10, 2024 at 2:59:19 PM (2 occurrences)
Last logged: 7:28:44 AM

Error adding entity sensor.sutro_alkalinity_sensor for domain sensor with platform sutro
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 600, in _async_add_entities
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 914, in _async_add_entity
    await entity.add_to_platform_finish()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1355, in add_to_platform_finish
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state
    state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
                                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1061, in __async_calculate_state
    state = self._stringify_state(available)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1006, in _stringify_state
    if (state := self.state) is None:
                 ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 543, in state
    value = self.native_value
            ^^^^^^^^^^^^^^^^^
  File "/config/custom_components/sutro/sensor.py", line 112, in native_value
    return float(self.coordinator.data["me"]["pool"]["latestReading"]["alkalinity"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: float() argument must be a string or a real number, not 'NoneType'

Not quite sure where to put in my token.

Not quite sure where to put in my token or what this second field is looking for. The docs say The only configuration parameter required is the Sutro API token.

Screenshot attached. But there are two fields. I've tried putting my token in both. My email in the first field and token in the second. and a few different permutations of things I could think of.

Screenshot 2024-07-07 at 9 42 41 PM

Version of the custom_component

VERSION = "0.0.1"
@*-MacBook-Pro-2 hass-sutro % git log
commit b391d25 (HEAD -> main, origin/main, origin/HEAD)
Author: Yuri Dogandjiev [email protected]
Date: Wed Jun 26 12:33:01 2024 -0700

Rev version in manifest

Describe the bug

Readme says only the token is needed but when going into the UI there are 2 fields.

Additional info of my env:

root@raspberrypi:~# docker ps
CONTAINER ID   IMAGE                                          COMMAND   CREATED        STATUS        PORTS     NAMES
dca5077c110c   ghcr.io/home-assistant/home-assistant:stable   "/init"   15 hours ago   Up 15 hours             homeassistant
root@raspberrypi:~# docker exec -it dca5077c110c /bin/bash
raspberrypi:/config# ls -l
total 816
-rw-r--r--    1 root     root             2 Jul  8 01:45 automations.yaml
drwxr-xr-x    4 root     root          4096 Jul  8 01:45 blueprints
-rw-r--r--    1 root     root           214 Jul  8 16:59 configuration.yaml
drwxr-xr-x    3 root     root          4096 Jul  8 01:45 custom_components
drwxr-xr-x    2 root     root          4096 Jul  8 01:45 deps
-rw-r--r--    1 root     root         18018 Jul  8 17:08 home-assistant.log
-rw-r--r--    1 root     root         22973 Jul  8 17:04 home-assistant.log.1
-rw-r--r--    1 root     root             0 Jul  8 17:04 home-assistant.log.fault
-rw-r--r--    1 root     root        335872 Jul  8 17:04 home-assistant_v2.db
-rw-r--r--    1 root     root         32768 Jul  8 17:12 home-assistant_v2.db-shm
-rw-r--r--    1 root     root        391432 Jul  8 17:12 home-assistant_v2.db-wal
-rw-r--r--    1 root     root             0 Jul  8 01:45 scenes.yaml
-rw-r--r--    1 root     root             0 Jul  8 01:45 scripts.yaml
-rw-r--r--    1 root     root           161 Jul  8 01:45 secrets.yaml
drwxr-xr-x    2 root     root          4096 Jul  8 01:45 tts
raspberrypi:/config# cat configuration.yaml 
# https://www.home-assistant.io/integrations/default_config/
default_config:

# https://www.home-assistant.io/integrations/logger/
logger:
  default: info
  logs:
    custom_components.integration_blueprint: debug
raspberrypi:/config# 
raspberrypi:/config# ls -l custom_components/
total 4
drwxr-xr-x    3 root     root          4096 Jul  8 01:26 sutro
raspberrypi:/config# ls -l custom_components/sutro/
total 60
-rw-r--r--    1 1000     1003          3265 Jul  8 00:58 __init__.py
drwxr-xr-x    2 root     root          4096 Jul  8 01:26 __pycache__
-rw-r--r--    1 1000     1003          5258 Jul  8 00:58 api.py
-rw-r--r--    1 1000     1003          5380 Jul  8 00:58 binary_sensor.py
-rw-r--r--    1 1000     1003          4319 Jul  8 00:58 config_flow.py
-rw-r--r--    1 1000     1003          1117 Jul  8 00:58 const.py
-rw-r--r--    1 1000     1003           469 Jul  8 00:58 en.json
-rw-r--r--    1 1000     1003          1126 Jul  8 00:58 entity.py
-rw-r--r--    1 1000     1003           390 Jul  8 00:58 manifest.json
-rw-r--r--    1 1000     1003          8882 Jul  8 00:58 sensor.py
raspberrypi:/config# 

Not able to find token in request when using Charles

Version of the custom_component

0.0.1

Configuration

None to supply

Describe the bug

I am unable to find any reference to https://api.mysutro.com/graphql when sending my traffic through Charles. I can only find https://api.mysutro.com/ and even in those, I am unable to find any Authorization header information. Can the documentation around retrieving this token be expanded upon to help those of us who aren't familiar with sniffing traffic?

Debug log

None to supply

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.