Giter Site home page Giter Site logo

homeassistant-greenchoice's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

homeassistant-greenchoice's Issues

Create sensor which shows daily data

The current sensor is cumulative and shows me the total gas/energy used up to that point in time. It would be nice to make the plugin generate a delta sensor, which actually shows the used resources per day.

Maybe other people would like this as well?

issue activating this

i was playing with this integration but it seems not to work

i get this error, do you have any idea?

Error while setting up platform greenchoice
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/greenchoice/sensor.py", line 55, in setup_platform
greenchoice_api.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 240, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/greenchoice/sensor.py", line 180, in update
json_result = json.loads(response.getresponse().read().decode('utf-8'))
File "/usr/local/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.7/jsoError while setting up platform greenchoice
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/greenchoice/sensor.py", line 55, in setup_platform
greenchoice_api.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 240, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/greenchoice/sensor.py", line 180, in update
json_result = json.loads(response.getresponse().read().decode('utf-8'))
File "/usr/local/lib/python3.7/json/init.py", line 348, in loads
return _default_decoder.decode(s)
File "/usr/local/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)n/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Gasmeter readings parsed incorrect

I thing the parsing of the API output is not correct. For the gas meter index 1 of the output is read. However, looking at the output I get when invoking the API manually, the gasmeter readings are at index 2. I think the code should look at the Product-field to determine the correct JSON-object for the meter readouts.
I also don't seem to get any 'Delivered' measurements but since I can't find any documentation about the Greenchoice API I'm not sure what the reason for this could be.

I pasted the output I got in the hope that it would help with the development.

[  
    {  
        "MeterstandenOutput": [  
            {
                "MinNieuweStand": 0,
                "MaxNieuweStand": 0,
                "Hoog": 2484,
                "Laag": 2905,
                "Product": 1
            }
        ],
        "DatumInvoer": "2020-12-30T00:00:00"
    },
    {
        "MeterstandenOutput": [
            {
                "MinNieuweStand": 0,
                "MaxNieuweStand": 0,
                "Hoog": 0,
                "Laag": 0,
                "Product": 2
            }
        ],
        "DatumInvoer": "2020-12-30T00:00:00"
    },
    {
        "MeterstandenOutput": [
            {
                "MinNieuweStand": 0,
                "MaxNieuweStand": 0,
                "Hoog": 2931,
                "Laag": 0,
                "Product": 3
            }
        ],
        "DatumInvoer": "2020-12-30T00:00:00"
    }
]

MeterstandenOutput does not show current meter.

The MeterstandenOutput shows all time registered, not how they are registered do far after last registration (note year).
Example: my meters are installed 2 years ago, so my meters has about 8000kW registered (all time), but I have 3000kW used since last year (from note year).
The MeterstandenOutput should be changed to the current meter stand registered from last note year.

Cannot find sensor

I added all info in my sensor.yaml ( config include !sensor.yaml)

  • platform: greenchoice
    name: meterstanden
    password: !secret greenchoicepass
    username: !secret greenchoiceuser
    overeenkomst_id: !secret greenchoicecontract

Of cource also installed the HACS Greenchoice.

I found my contract id with the curl instructions.
But now I cannot find a sensor anywhere on HA.

Integration needs a version number to keep running in HA

Running the integration the following error comes up:

No 'version' key in the manifest file for custom integration 'greenchoice'.
This will not be allowed in a future version of Home Assistant.
Please report this to the maintainer of 'greenchoice'

How to test

Hi Jesse,

I have installed this plugin. And I received a id.
Everything is ok, but how can i implement or test this?

I can't find any entitie with 'meterstand' of with 'greenchoice'.

What is the clientID to be used for GreenChoice API?

Hi, than you for creating this Custom sensor.

I try to retreive my access token but when I enter the command in POSTman, I get the following result:

{
"error": "invalid_clientId",
"error_description": "ClientId should be sent."
}

I've tried different entries for ClientID, like my e-mail address, customer number and even just my name, everythime with the same error.

Do I need to add my ClientID between special characters due to the fact it's an e-mailaddress? Or does it have something to do with my password (there are special characters in it).

Can you please help?

Thanks!
Michael

Error while setting up greenchoice platform for sensor

Hi,

I have obtained the contract id, and put it together with username/password in secrets.yaml. I'm getting the following error in the log file while trying to setup this component.

2021-04-11 14:23:48 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up greenchoice platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 205, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/greenchoice/sensor.py", line 57, in setup_platform
    greenchoice_api.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 278, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/greenchoice/sensor.py", line 203, in update
    currentEnergy = [x for x in json_result if x['MeterstandenOutput'][0]['Product'] == 1]
  File "/config/custom_components/greenchoice/sensor.py", line 203, in <listcomp>
    currentEnergy = [x for x in json_result if x['MeterstandenOutput'][0]['Product'] == 1]
TypeError: string indices must be integers

sensors/greenchoice.yaml

- platform: greenchoice
  name: meterstanden
  password: !secret greenchoicepass
  username: !secret greenchoiceuser
  overeenkomst_id: !secret greenchoicecontract

Any idea what I am doing wrong?

Thanks,

Vic

Error while setting up greenchoice platform on HA release 2021.11

When I start Home Assistant the following is shown in log and the custom integration is not loaded.

Error while setting up greenchoice platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 249, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 52, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/greenchoice/sensor.py", line 57, in setup_platform
    greenchoice_api.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 277, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/greenchoice/sensor.py", line 190, in update
    response.request("POST", "/token", body = self._tokenquery, headers = self._tokenheaders)
  File "/usr/local/lib/python3.9/http/client.py", line 1279, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1325, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1274, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.9/http/client.py", line 1034, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.9/http/client.py", line 974, in send
    self.connect()
  File "/usr/local/lib/python3.9/http/client.py", line 1448, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/usr/local/lib/python3.9/ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/lib/python3.9/ssl.py", line 1040, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.9/ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:1129)

Do you want me to add GitHub actions?

If you want, I can add some advanced CI to your repo in a PR. Let me know if you want that.

  • Do you want to enable auto-formatting?
  • Do you want packaged or independent (I recommend packaged because I can send updates)?

No sensor created?? How can I use the data retrieved?

I succesfully installed the custom component.
When looking in the debug logfiles of HA, I also see the data is retrieved from Greenchoice.

However, I can not find en entity in HA with attributes of something like that.
How exactly can I use the data retrieved bij the Greenchoice Integration?

Add integration within Home Assistant UI

Besides yaml configuration also make it possible to add the configuration via the Home Assistant user interface.
In that case contract(s) could also be retrieved and displayed and selected by user. Or generate sensors for all contracts so that user can hide the contracts that he doesn't need.

More API commands available?

Hi Jesse,

The plugin is working fine, thanks for that!
Do you happen to know where to find any API documentation?
I would like to extend your plugin with the "Tarieven" (tariffs), so I can see how much Euro is "consumed" rather than kWh.
The only thing missing is the right URL.

Thanks in advance.

Best,
Ron

KeyError: 'access_token'

I've installed the component and configured it. I was able to get my access token and contract ID via Postman. However, when running the platform I'm getting the following issue:

2020-05-07 13:39:39 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up greenchoice platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
return fut.result()
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/greenchoice/sensor.py", line 55, in setup_platform
greenchoice_api.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 240, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/greenchoice/sensor.py", line 175, in update
self.token = json_result["access_token"]
KeyError: 'access_token'

Looks like the platform can't get the access_token programmatically from the Greencoice API service anymore

Doesn't work if you don't have gas

Just tried out the integration, but get an error during setup:

Error while setting up greenchoice platform for sensor
Traceback (most recent call last):
  File "/home/hass/.local/lib/python3.8/site-packages/homeassistant/helpers/entity_platform.py", line 184, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/hass/.homeassistant/custom_components/greenchoice/sensor.py", line 56, in setup_platform
    greenchoice_api.update()
  File "/home/hass/.local/lib/python3.8/site-packages/homeassistant/util/__init__.py", line 239, in wrapper
    result = method(*args, **kwargs)
  File "/home/hass/.homeassistant/custom_components/greenchoice/sensor.py", line 195, in update
    self.result["currentGas"] = json_result[1]["MeterstandenOutput"][0]["Hoog"]
IndexError: list index out of range

so it looks like it can't handle the result if there's no gas output.

Authorization has been denied for this request when using curl

I'm trying to get the contract id using the curl method.

I've succeeded in getting the token with my username/password. When executing the second command with the token, I get the following response:

{"Message":"Authorization has been denied for this request."}

What could be wrong here? I've tried to paste the following as token (replacing ******** directly after Authorization Bearer:

  • full token, so everything between, and including, {} (with this I get a lot of error messages, so probably not the one)
  • token with quotes ""
  • token without quotes

Any other options? Or possible root causes?

Screenshot Postman

Would you be so kind to add screenshots to the readme section how to input the POST request?
I am not able to figure that out and I would love to use this component.

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.