Skip to content

Commit

Permalink
erreur month
Browse files Browse the repository at this point in the history
integration de sonarQube( quality code )
modification valeur du yesterday
manage multi linky
  • Loading branch information
saniho committed Jan 10, 2021
1 parent d3c127d commit 9a941a2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 26 deletions.
6 changes: 0 additions & 6 deletions .scannerwork/report-task.txt

This file was deleted.

30 changes: 13 additions & 17 deletions custom_components/apiEnedis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from homeassistant.exceptions import ConfigEntryNotReady

from homeassistant.helpers.update_coordinator import DataUpdateCoordinator, UpdateFailed
except:
except ImportError:
# si py test
class DataUpdateCoordinator:
def __init__(self):
Expand Down Expand Up @@ -41,6 +41,7 @@ def callback( var1 ):

async def async_setup(hass, config):
"""Import integration from config."""
hass.data.setdefault(DOMAIN, {})
conf = config.get(DOMAIN)
if conf:
for enedisconf in conf:
Expand All @@ -56,14 +57,13 @@ async def async_setup(hass, config):

async def _async_setup_entry(hass, config_entry):
"Set up this integration using UI."
_LOGGER.exception("run myEnedis for ??")
coordinator = sensorEnedisCoordinator( hass, config_entry)
_LOGGER.exception("run myEnedis for ?? ")
coordinator = sensorEnedisCoordinator( hass, config_entry)
await coordinator.async_setup()

async def _enable_scheduled_myEnedis(*_):
"""Activate the data update coordinator."""
coordinator.update_interval = timedelta(
#seconds=config_entry.options.get(CONF_SCAN_INTERVAL, DEFAULT_SCAN_INTERVAL)
seconds=DEFAULT_SCAN_INTERVAL
)
await coordinator.async_refresh()
Expand All @@ -80,14 +80,14 @@ async def _enable_scheduled_myEnedis(*_):
EVENT_HOMEASSISTANT_STARTED, _enable_scheduled_myEnedis
)

hass.data[DOMAIN] = coordinator
hass.data[DOMAIN][config_entry.entry_id] = coordinator
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, PLATFORM)
)
return True

async def async_setup_entry(hass, config_entry) -> bool:

_LOGGER.exception("run myEnedis - sensorEnedisCoordinator %s" %(config_entry.data))
coordinator = sensorEnedisCoordinator( hass, config_entry)
await coordinator.async_setup()
async def _enable_scheduled_myEnedis(*_):
Expand All @@ -108,8 +108,9 @@ async def _enable_scheduled_myEnedis(*_):
EVENT_HOMEASSISTANT_STARTED, _enable_scheduled_myEnedis
)
undo_listener = config_entry.add_update_listener(update_listener)
hass.data[DOMAIN] = coordinator
hass.data[DOMAIN][config_entry.entry_id] = coordinator
for component in [PLATFORM]:
_LOGGER.exception("run myEnedis - component %s" %(component))
hass.async_create_task(
hass.config_entries.async_forward_entry_setup(config_entry, component)
)
Expand All @@ -122,13 +123,9 @@ async def update_listener(hass, config_entry):
async def async_unload_entry(hass, config_entry):
"""Unload myEnedis Entry from config_entry."""
hass.services.async_remove(DOMAIN, myENEDIS_SERVICE)

hass.data[DOMAIN].async_unload()

hass.data[DOMAIN][config_entry.entry_id].async_unload()
await hass.config_entries.async_forward_entry_unload(config_entry, "sensor")

hass.data.pop(DOMAIN)

return True

class sensorEnedisCoordinator( DataUpdateCoordinator):
Expand Down Expand Up @@ -179,7 +176,7 @@ async def async_set_options(self):
_LOGGER.info("async_set_options - proc -- done ")

def update_MyEnedis(self):
_LOGGER.info("update_MyEnedis")
_LOGGER.info("update_MyEnedis pre-getini for %s"%(self.config_entry.options['token']))
if (not self.myEnedis.getInit()):
_LOGGER.info("getInit()")
delai_interval = CONF_DELAY # delai de rafraichissement de l'appel API
Expand Down Expand Up @@ -233,10 +230,9 @@ def async_unload(self):

async def options_updated_listener(hass, entry):
"""Handle options update."""

_LOGGER.info("options_updated_listener ")
hass.data[DOMAIN].update_interval = timedelta(
hass.data[DOMAIN][entry.entry_id].update_interval = timedelta(
seconds=DEFAULT_SENSOR_INTERVAL
)
await hass.data[DOMAIN].async_request_refresh()
_LOGGER.info("options_updated_listener - done -- ")
await hass.data[DOMAIN][entry.entry_id].async_request_refresh()
_LOGGER.info("options_updated_listener - done -- ")
3 changes: 2 additions & 1 deletion custom_components/apiEnedis/myEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import logging
try:
from . import messages
except:

except ImportError:
import messages

__nameMyEnedis__ = "myEnedis"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/apiEnedis/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async def async_setup_entry(
) -> None:
"""Set up the myEnedis sensor platform."""
entities = []
myEnedis_Cordinator = hass.data[DOMAIN]
myEnedis_Cordinator = hass.data[DOMAIN][entry.entry_id]
entities.append(myEnedisSensorCoordinator(myEnedis_Cordinator))
entities.append(myEnedisSensorYesterdayCostCoordinator(myEnedis_Cordinator))
async_add_entities(entities)
Expand Down
3 changes: 2 additions & 1 deletion custom_components/apiEnedis/testEnedis.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def testMulti():
#for qui in ["ENEDIS9"]:
#for qui in ["ENEDIS","ENEDIS2","ENEDIS3","ENEDIS4","ENEDIS15"]:
#for qui in ["ENEDIS18"]:
for qui in ["ENEDIS19"]:
#for qui in ["ENEDIS19"]:
for qui in ["ENEDIS"]:
token = mon_conteneur[qui]['TOKEN']
PDL_ID = mon_conteneur[qui]['CODE']
print(qui , "*", token, PDL_ID)
Expand Down
Binary file added img/enedis-linky-erdf_8277.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9a941a2

Please sign in to comment.