mirror of
				https://github.com/CCOSTAN/Home-AssistantConfig.git
				synced 2025-10-31 02:37:25 +00:00 
			
		
		
		
	Update for Duke Energy Beta Testing #383
This commit is contained in:
		
							
								
								
									
										80
									
								
								config/custom_components/sensor/duke_energy.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										80
									
								
								config/custom_components/sensor/duke_energy.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| """ | ||||
| Support for Duke Energy Gas and Electric meters. | ||||
|  | ||||
| For more details about this component, please refer to the documentation at | ||||
| https://home-assistant.io/components/sensor/duke_energy/ | ||||
| """ | ||||
| import logging | ||||
|  | ||||
| import voluptuous as vol | ||||
|  | ||||
| from homeassistant.components.sensor import PLATFORM_SCHEMA | ||||
| from homeassistant.const import CONF_USERNAME, CONF_PASSWORD | ||||
| from homeassistant.helpers.entity import Entity | ||||
| import homeassistant.helpers.config_validation as cv | ||||
| import homeassistant.util as util | ||||
|  | ||||
| REQUIREMENTS = ['pydukeenergy==0.0.4'] | ||||
|  | ||||
| _LOGGER = logging.getLogger(__name__) | ||||
|  | ||||
| PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ | ||||
|     vol.Required(CONF_USERNAME): cv.string, | ||||
|     vol.Required(CONF_PASSWORD): cv.string, | ||||
| }) | ||||
|  | ||||
|  | ||||
| def setup_platform(hass, config, add_devices, discovery_info=None): | ||||
|     """Display the current season.""" | ||||
|     from pydukeenergy.api import DukeEnergy, DukeEnergyException | ||||
|  | ||||
|     try: | ||||
|         duke = DukeEnergy(config.get(CONF_USERNAME), config.get(CONF_PASSWORD)) | ||||
|     except DukeEnergyException: | ||||
|         _LOGGER.error("Failed to setup Duke Energy") | ||||
|         return False | ||||
|  | ||||
|     meters = duke.get_meters() | ||||
|     sensors = [] | ||||
|     for meter in meters: | ||||
|         sensors.append(DukeEnergyMeter(meter)) | ||||
|     add_devices(sensors) | ||||
|  | ||||
|     return True | ||||
|  | ||||
|  | ||||
| class DukeEnergyMeter(Entity): | ||||
|     """Representation of a Duke Energy meter.""" | ||||
|  | ||||
|     def __init__(self, meter): | ||||
|         """Initialize the meter.""" | ||||
|         self.duke_meter = meter | ||||
|  | ||||
|     @property | ||||
|     def name(self): | ||||
|         """Return the name.""" | ||||
|         return "duke_energy_" + self.duke_meter.id | ||||
|  | ||||
|     @property | ||||
|     def state(self): | ||||
|         """Return yesterdays usage.""" | ||||
|         return self.duke_meter.get_usage() | ||||
|  | ||||
|     @property | ||||
|     def unit_of_measurement(self): | ||||
|         """Return the unit of measurement this sensor expresses itself in.""" | ||||
|         return self.duke_meter.get_unit() | ||||
|  | ||||
|     @property | ||||
|     def device_state_attributes(self): | ||||
|         """Return the state attributes.""" | ||||
|         attributes = { | ||||
|             "lastBillsUsage": self.duke_meter.get_total(), | ||||
|             "lastBillsAverageUsage": self.duke_meter.get_average(), | ||||
|             "lastBillsDaysBilled": self.duke_meter.get_days_billed() | ||||
|         } | ||||
|         return attributes | ||||
|  | ||||
|     def update(self): | ||||
|         """Update meter.""" | ||||
|         self.duke_meter.update() | ||||
| @@ -1,18 +1,15 @@ | ||||
| #------------------------------------------- | ||||
| #  PiHole ad Blocking Related Packages | ||||
| #------------------------------------------- | ||||
| # homeassistant: | ||||
| #   customize: | ||||
| # | ||||
| #     sensor.pihole_ads_percentage_today: | ||||
| #       friendly_name: Percentage of Ad Traffic Blocked | ||||
| #       unit_of_measurement: '%' | ||||
| #       icon: mdi:ticket-percent | ||||
| # | ||||
| #     group.pihole: | ||||
| #       homebridge_hidden: true | ||||
| #------------------------------------------- | ||||
| ###################################################################################################### | ||||
| ### @Tesla Powerwall - https://www.vcloudinfo.com/2018/01/going-green-to-save-some-green-in-2018.html | ||||
| # # @CCOSTAN | ||||
| # Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig | ||||
| ###################################################################################################### | ||||
|  | ||||
| sensor: | ||||
|  | ||||
|   - platform: duke_energy | ||||
|     username: !secret duke_energy_username | ||||
|     password: !secret duke_energy_password | ||||
|  | ||||
|   - platform: rest | ||||
|     name: House now | ||||
|     resource: http://192.168.10.90/api/meters/aggregates | ||||
| @@ -62,4 +59,4 @@ group: | ||||
|  | ||||
| # | ||||
| # automation: | ||||
| # Located in the Grafana package.  Tweets out Solar Production Daily!    | ||||
| # Located in the Grafana package.  Tweets out Solar Production Daily! | ||||
|   | ||||
| @@ -275,6 +275,7 @@ automation: | ||||
|               "Build your own DIY Outdoor Smart Home LED strips - (https://www.vcloudinfo.com/2017/08/diy-outdoor-smart-home-led-strips.html)", | ||||
|               "Breakdown of the entire smart home - (https://www.vcloudinfo.com/2017/07/my-smart-home-look-at-parts-that-make.html)", | ||||
|               "Build your own Home Alarm System - (https://www.vcloudinfo.com/2017/06/building-my-home-alarm-system-hardware.html)", | ||||
|               "Adding a Mixer and AMP to this Text to Speech solution changed the Smart Home COMPLETELY! (https://www.vcloudinfo.com/2017/07/giving-voice-to-smart-home.html)", | ||||
|               "Some of my favorite #Docker Containers that I am using - (https://www.vcloudinfo.com/2018/06/rolling-out-some-new-docker-containers.html)", | ||||
|               "Be Sure to follow all of my Twitter Accounts! @CCostan and my HOUSE bot @BearStoneHA!", | ||||
|               "Be sure to like me on Facebook and join our HA group! (https://www.facebook.com/groups/HomeAssistant/) (https://www.facebook.com/VMwareInfo/) (https://www.facebook.com/BearStoneHA/)", | ||||
|   | ||||
| @@ -36,6 +36,7 @@ tweet_engine_setup: | ||||
|                 "Build your own DIY Outdoor Smart Home LED strips - (https://www.vcloudinfo.com/2017/08/diy-outdoor-smart-home-led-strips.html)", | ||||
|                 "Breakdown of the entire smart home - (https://www.vcloudinfo.com/2017/07/my-smart-home-look-at-parts-that-make.html)", | ||||
|                 "Build your own Home Alarm System - (https://www.vcloudinfo.com/2017/06/building-my-home-alarm-system-hardware.html)", | ||||
|                 "Adding a Mixer and the AMP to this Text to Speech solution changed the Smart Home! (https://www.vcloudinfo.com/2017/07/giving-voice-to-smart-home.html)", | ||||
|                 "Some of my favorite #Docker Containers that I am using - (https://www.vcloudinfo.com/2018/06/rolling-out-some-new-docker-containers.html)", | ||||
|                 "10 year safety check.  If you haven't done it yet, you need to! (https://www.vcloudinfo.com/2017/06/psa-check-out-your-smoke-detectors-once.html)" | ||||
|               ], | ||||
|   | ||||
| @@ -16,6 +16,8 @@ camera3_url: http://192.168.10.23:88/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=a | ||||
| forecast_key: ForcastKeyphrase | ||||
| fitbit_user: User@email.com | ||||
| fitbit_password: abcdefghijklmnopqrstuvwxyz0123456789 | ||||
| duke_energy_username: user@email.com | ||||
| duke_energy_password: SuperSecretCode | ||||
| juicenet_access_token: abcdefghijklmnopqrstuvwxyz0123456789 | ||||
| bedroom_restart_on: "/usr/bin/curl -k 'http://192.168.10.127:2323/?cmd=restartApp&password=SecretPassWord'" | ||||
| nest_client_id: secret_nest_client_id | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 122 KiB After Width: | Height: | Size: 114 KiB | 
		Reference in New Issue
	
	Block a user