Skip to content

Commit

Permalink
Release 0.2.2
Browse files Browse the repository at this point in the history
Release 0.2.2
  • Loading branch information
jobvk authored Sep 4, 2022
2 parents 61c4e3f + d07e737 commit e7fa282
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 19 deletions.
31 changes: 16 additions & 15 deletions custom_components/windcentrale/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@
DEFAULT_SHOW_ON_MAP = False

# Format:
# Name: [Manufacturer, Model, Location, Latitude, Longitude, Total Shares, StartDate]
# Name: [Manufacturer, Model, Location, Latitude, Longitude, Total Shares, Start Date, Energy Prognoses (kWh)]
WINDTURBINES_LIST = {
"De Grote Geert": ["Enercon", "E-70", "Meedhuizen", 53.27988, 6.9594, 9910, dt.datetime(2013, 1, 1)],
"De Jonge Held": ["Enercon", "E-70", "Meedhuizen", 53.27725, 6.95859, 10154, dt.datetime(2013, 1, 1)],
"Het Rode Hert": ["Vestas", "V80", "Culemborg", 51.935829, 5.192112, 6648, dt.datetime(2014, 1, 1)] ,
"De Ranke Zwaan": ["Vestas", "V80", "Culemborg", 51.934916, 5.199874, 6164, dt.datetime(2014, 1, 1)],
"De Witte Juffer": ["Vestas", "V80", "Culemborg", 51.935174, 5.195846, 5721, dt.datetime(2014, 1, 1)],
"De Bonte Hen": ["Vestas", "V52", "Burgerbrug", 52.757049, 4.684686, 5579, dt.datetime(2014, 1, 1)],
"De Trouwe Wachter": ["Vestas", "V52", "Burgerbrug", 52.758741, 4.686049, 5602, dt.datetime(2014, 1, 1)],
"De Blauwe Reiger": ["Vestas", "V52", "Burgerbrug", 52.760478, 4.687449, 5534, dt.datetime(2014, 1, 1)],
"De Vier Winden": ["Vestas", "V52", "Burgerbrug", 52.762214, 4.688828, 5512, dt.datetime(2014, 7, 1)],
"De Boerenzwaluw": ["Enercon", "E-44", "Burum", 53.265376, 6.214152, 3000, dt.datetime(2016, 8, 1)],
"Het Vliegend Hert": ["Lagerwey", "L82", "Rouveen", 52.59131, 6.22014, 9751, dt.datetime(2018, 9, 15)]
"De Grote Geert": ["Enercon", "E-70", "Meedhuizen", 53.27988, 6.9594, 9910, dt.datetime(2013, 1, 1), 4900000],
"De Jonge Held": ["Enercon", "E-70", "Meedhuizen", 53.27725, 6.95859, 10154, dt.datetime(2013, 1, 1), 5000000],
"Het Rode Hert": ["Vestas", "V80", "Culemborg", 51.935829, 5.192112, 6648, dt.datetime(2014, 1, 1), 3300000] ,
"De Ranke Zwaan": ["Vestas", "V80", "Culemborg", 51.934916, 5.199874, 6164, dt.datetime(2014, 1, 1), 3000000],
"De Witte Juffer": ["Vestas", "V80", "Culemborg", 51.935174, 5.195846, 5721, dt.datetime(2014, 1, 1), 2800000],
"De Bonte Hen": ["Vestas", "V52", "Burgerbrug", 52.757049, 4.684686, 5579, dt.datetime(2014, 1, 1), 2800000],
"De Trouwe Wachter": ["Vestas", "V52", "Burgerbrug", 52.758741, 4.686049, 5602, dt.datetime(2014, 1, 1), 2800000],
"De Blauwe Reiger": ["Vestas", "V52", "Burgerbrug", 52.760478, 4.687449, 5534, dt.datetime(2014, 1, 1), 2800000],
"De Vier Winden": ["Vestas", "V52", "Burgerbrug", 52.762214, 4.688828, 5512, dt.datetime(2014, 7, 1), 2800000],
"De Boerenzwaluw": ["Enercon", "E-44", "Burum", 53.265376, 6.214152, 3000, dt.datetime(2016, 8, 1), 1500000],
"Het Vliegend Hert": ["Lagerwey", "L82", "Rouveen", 52.59131, 6.22014, 9751, dt.datetime(2018, 9, 15), 5000000]
}

# Format:
Expand All @@ -52,9 +52,10 @@
"powertotal": ["Power Total", SensorDeviceClass.POWER, POWER_KILO_WATT, None, "power"],
"powerpershare": ["Power Per Share", SensorDeviceClass.POWER, POWER_WATT, None, "power_per_share"],
"powerpercentage": ["Power Percentage", None, PERCENTAGE, "mdi:percent", "power_percentage"],
"rpm": ["Revolutions Per Minute", None, "RPM", "mdi:speedometer", "rpm"],
"energy": ["Energy Management", SensorDeviceClass.ENERGY, ENERGY_KILO_WATT_HOUR, None, "year_production"],
"yearproduction": ["Production This Year", SensorDeviceClass.ENERGY, ENERGY_KILO_WATT_HOUR, None, "year_production"],
"rpm": ["Revolutions Per Minute", None, "RPM", "mdi:gauge", "rpm"],
"energy": ["Energy", SensorDeviceClass.ENERGY, ENERGY_KILO_WATT_HOUR, None, "year_production"],
"energyshares": ["Energy shares", SensorDeviceClass.ENERGY, ENERGY_KILO_WATT_HOUR, None, "year_production"],
"energyprognoses": ["Energy Prognoses This Year", None, PERCENTAGE, "mdi:percent", "year_production"],
"runtimeyear": ["Hours Run This Year", None, TIME_HOURS, "mdi:calendar-clock", "year_runtime"],
"runtimetotal": ["Hours Run Total", None, TIME_HOURS, "mdi:calendar-clock", "total_runtime"],
"runpercentage": ["Run Percentage", None, PERCENTAGE, "mdi:percent", "year_runtime"],
Expand Down
2 changes: 1 addition & 1 deletion custom_components/windcentrale/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"iot_class": "cloud_polling",
"dependencies": [],
"codeowners": ["@jobvk"],
"version": "0.2.1",
"version": "0.2.2",
"loggers": ["boto3"]
}
7 changes: 5 additions & 2 deletions custom_components/windcentrale/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def extra_state_attributes(self):
if self.type == "windturbine":
attr["Id"] = self._windturbine.id
attr["Shares"] = self._windturbine.shares
attr["Total_Shares"] = self._windturbine.total_shares
attr[ATTR_LOCATION] = self._windturbine.location
if self._windturbine.show_on_map:
attr[ATTR_LATITUDE] = self._windturbine.latitude
Expand All @@ -135,7 +136,7 @@ def extra_state_attributes(self):
attr["Degrees"] = self.degrees.get(self._state)
elif self.type == "windspeed" or self.type == "powertotal" or self.type == "powerpershare" or self.type == "powerpercentage" or self.type == "rpm":
attr[CONF_STATE_CLASS] = SensorStateClass.MEASUREMENT
elif self.type == "energy" or self.type == "yearproduction":
elif self.type == "energy" or self.type == "energyshares":
attr[ATTR_LAST_RESET] = datetime(datetime.now().year, 1, 1)
attr[CONF_STATE_CLASS] = SensorStateClass.TOTAL
return attr
Expand All @@ -153,10 +154,12 @@ def update(self):
if self._windturbine.live_data is not None:
if self.type == "windturbine":
self._state = self._windturbine.live_data[self._sensor] * self._windturbine.shares
elif self.type == "energy":
elif self.type == "energyshares":
self._state = self._windturbine.live_data[self._sensor] / self._windturbine.total_shares * self._windturbine.shares
elif self.type == "runpercentage":
self._state = round(timedelta(hours=self._windturbine.live_data[self._sensor]) / (datetime.now() - datetime(datetime.now().year, 1, 1)) * 100, 2)
elif self.type == "energyprognoses":
self._state = round((self._windturbine.live_data[self._sensor] / self._windturbine.energy_prognoses) * 100, 2)
else:
self._state = self._windturbine.live_data[self._sensor]

Expand Down
3 changes: 2 additions & 1 deletion custom_components/windcentrale/wind.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def __init__(self, wind, hass, windturbine_name, windturbine_code, windturbine_s
self.latitude = WINDTURBINES_LIST[windturbine_name][3]
self.longitude = WINDTURBINES_LIST[windturbine_name][4]
self.total_shares = WINDTURBINES_LIST[windturbine_name][5]
self.startDate = WINDTURBINES_LIST[windturbine_name][6]
self.start_date = WINDTURBINES_LIST[windturbine_name][6]
self.energy_prognoses = WINDTURBINES_LIST[windturbine_name][7]
self.liveapi = LiveAPI(self.hass, self.wind, self.id, self.name)
#self.productionapi = ProductionAPI(self.hass, self.name, self.id, self.shares)

Expand Down

0 comments on commit e7fa282

Please sign in to comment.