Giter Site home page Giter Site logo

repsolluzygas's Introduction

This component only works on HA 0.96 and later.

Custom component for Repsol Luz y Gas

A platform which allows you to get data from Repsol Luz y Gas website.

Changelog

Version 1.2 - 06/04/2024:

  • updated code to cater for API changes (thanks to @jesusperiago)
  • cleaned logging (thanks to @jesusperiago)

Version 1.1 - 06/12/2021:

  • Added 2 new sensors: Last Invoice Amount (Numeric) and Last Invoice Status (Boolean). Last Invoice Amount (LIA): represents the amount of the last amount. Last Invoice Status (LIS): it's a boolean that returns if invoice was paid or not.

Know Limitations

  • This component is limited to 1 house - MultiHouses is not working
  • Data is updated every 2 hours

Current Features

  • Read data from repsolluzygas.com.
  • Multi contracts per house. (only working with 1 house)
  • Available sensors: Amount, Consumption, Total Days, Amount Variable, Amount Fixed, Average Daily Cost, Number of contracts

Installation

Install the component manually by putting the files from /custom_components/repsolluzygas/ in your folder <config directory>/custom_components/repsolluzygas/

Screenshot

Repsol Luz y Gas

Capture

Capture1

Capture2

Configuration

Example configuration.yaml:

sensor:
  - platform: repsolluzygas
    username: <YourEmail>
    password: <Password>

repsolluzygas's People

Contributors

bzzoiro avatar jesusperiago avatar tslpre avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar

repsolluzygas's Issues

Do user & pw have to be into brackets?

when placing repsolluzygas folder into custom components and validate config in home assisnts it says 'integration not found' what am I missing? thnak you

no bills

En repsol_api.py, linea 183, se produce un error cuando aun no tenemos ninguna factura emitida. Es el caso de un nuevo cliente al que aun no se le han emitido facturas.

Async and Configflow

Dears,

I've almost fully merged the code for a Async version and using Configflow. I just need to address an issue with the Next Invoice Amount sensor, which I've just submitted a Pull request for, and try to make it able to manage multi-contracts.

@bzzoiro and @tslpre, do you guys prefer me to get a full code pull request or how shall I make it?

In addition, does anyone with a gas contract can pull the data that the API response for the gas invoices and costs? I had it before, but right now I do not get the gas from Repsol anymore.

Cheers,

Invoice List

Using the new interface method created in sensor_api.py : get_invoices create new virtual sensors (check what are the best sensor to display a list of invoices)

Error adding entities for domain sensor with platform repsolluzygas

Hello to everyone, the integration is not working and entities are not present
Installed manually and trought HACS
Username and Password are correct
Home Assistant 2022.2.6
I dont have any invoice... maybe is that?
Any idea?

Thanks

**_Logger: homeassistant.components.sensor
Source: custom_components/repsolluzygas/sensor.py:61
Integration: Sensor (documentation, issues)
First occurred: 14:44:44 (2 occurrences)
Last logged: 14:44:44

Error adding entities for domain sensor with platform repsolluzygas
Error while setting up repsolluzygas platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
await asyncio.gather(tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 614, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 782, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 539, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 572, in _async_write_ha_state
state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 545, in stringify_state
if (state := self.state) is None:
File "/config/custom_components/repsolluzygas/sensor.py", line 61, in state
data = self.client.data.get(self.variable, 0)
AttributeError: 'RepsolLuzYGasSensor' object has no attribute 'data'
*

Version 1.1. Error in python if you don't have any invoice.

I changed to Redsol this month and don't have any invoice.
Last version don't support this case , the python program broke with '0 out of index' and the installation dont progress.
After modify the python progran to remove last invoice logic all is working great.

Next month ,i wil recover the v1,1 code.

Thanks for this integration
Regards

No funciona en HA 2024

Alguien le está funcionando? he probado con el repsol_api modificado que encontrado en otra entrada pero tampoco funciona.

2024-01-22 18:10:32.727 ERROR (MainThread) [homeassistant.components.sensor] repsolluzygas: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 573, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1218, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/repsolluzygas/sensor.py", line 73, in update
self.client.update()
File "/config/custom_components/repsolluzygas/repsol_api.py", line 186, in update
data['last_invoice_amount'] = invoices[0]['amount']
~~~~~~~~^^^
IndexError: list index out of range
2024-01-22 18:10:33.100 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform repsolluzygas
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1282, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/config/custom_components/repsolluzygas/sensor.py", line 61, in state
data = self.client.data.get(self.variable, 0)
^^^^^^^^^^^^^^^^
AttributeError: 'RepsolLuzYGasSensor' object has no attribute 'data'
2024-01-22 18:10:33.108 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up repsolluzygas platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1282, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 945, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1066, in _async_write_ha_state
state, attr, capabilities, shadowed_attr = self.__async_calculate_state()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1003, in __async_calculate_state
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 951, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/config/custom_components/repsolluzygas/sensor.py", line 61, in state
data = self.client.data.get(self.variable, 0)
^^^^^^^^^^^^^^^^
### AttributeError: 'RepsolLuzYGasSensor' object has no attribute 'data'

Error ¿changes in the api ?

In the last days i have errors and this integration is not working

2023-09-10 12:58:42.343 ERROR (MainThread) [homeassistant.components.sensor] repsolluzygas: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 573, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 938, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/repsolluzygas/sensor.py", line 73, in update
self.client.update()
File "/config/custom_components/repsolluzygas/repsol_api.py", line 166, in update
contracts = self.get_contracts(uid, signature, tstamp)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/repsolluzygas/repsol_api.py", line 88, in get_contracts
data = data[0]
~~~~^^^
KeyError: 0
2023-09-10 12:58:44.432 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform repsolluzygas
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1002, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 730, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 771, in _async_generate_attributes
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/config/custom_components/repsolluzygas/sensor.py", line 61, in state
data = self.client.data.get(self.variable, 0)
^^^^^^^^^^^^^^^^
AttributeError: 'RepsolLuzYGasSensor' object has no attribute 'data'
2023-09-10 12:58:45.243 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up repsolluzygas platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 367, in _async_setup_platform
await asyncio.gather(*pending)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 752, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1002, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 730, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 830, in _async_write_ha_state
state, attr = self._async_generate_attributes()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 771, in _async_generate_attributes
state = self._stringify_state(available)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 736, in _stringify_state
if (state := self.state) is None:
^^^^^^^^^^
File "/config/custom_components/repsolluzygas/sensor.py", line 61, in state
data = self.client.data.get(self.variable, 0)
^^^^^^^^^^^^^^^^
AttributeError: 'RepsolLuzYGasSensor' object has no attribute 'data'

Unable to install through HACS

For some reason, this component does not install through HACS. Comparing it with my fork (which I tested and it works), I've noticed that in hacs.json there were two different "version" keys. I've removed the extra/wrong one.

Will try to publish it again (not sure I've got the rights) and see if that was the culprit...

Total Days and Last Invoice Amount Error + Gas Sensor Enquiry

Hi,

My last invoice sensor is retrieving the Gas Invoice amount, not the last electricity bill.

image

image

The total days is reporting 0, though on the web it shows 22 days:

image

image

By the way, would it be possible to have a Gas sensor (including consumption and amount)? In my case, I have both consumptions under the same contract and everything comes together on the same page.

Thanks for the integration and your work on this.

error despues de instalar 2021.12.1

No funciona despues de instalar 2021.12.1, desde entonces me da el siguiente error

Logger: homeassistant.components.sensor
Source: custom_components/repsolluzygas/sensor.py:61
Integration: Sensor (documentation, issues)
First occurred: 8:37:07 AM (2 occurrences)
Last logged: 8:37:07 AM

Error adding entities for domain sensor with platform repsolluzygas
Error while setting up repsolluzygas platform for sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 613, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 748, in add_to_platform_finish
self.async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 505, in async_write_ha_state
self._async_write_ha_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 538, in _async_write_ha_state
state = self._stringify_state()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 511, in _stringify_state
if (state := self.state) is None:
File "/config/custom_components/repsolluzygas/sensor.py", line 61, in state
data = self.client.data.get(self.variable, 0)
AttributeError: 'RepsolLuzYGasSensor' object has no attribute 'data'

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.