-
-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Bump hatasmota to 0.0.29 #43013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
balloob
merged 8 commits into
home-assistant:dev
from
emontnemery:bump_hatasmota_0.0.28
Nov 11, 2020
Merged
Bump hatasmota to 0.0.29 #43013
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a1fec1e
Translate between Tasmota and HA unit constants
emontnemery 9745dde
Adapt to new status sensors
emontnemery 3d763f1
Add test
emontnemery 65e653a
Bump hatasmota to 0.0.28
emontnemery 67f8512
Don't pass hass.async_create_task to hatasmota
emontnemery 64c1605
Add support for SSID status sensor
emontnemery c16483e
State of last restart sensor as UTC iso-string, add test
emontnemery 23804e3
Bump hatasmota to 0.0.29
emontnemery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,19 @@ | |
|
|
||
| from hatasmota import status_sensor | ||
| from hatasmota.const import ( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol at all these renames. You can also do |
||
| CONCENTRATION_MICROGRAMS_PER_CUBIC_METER as TASMOTA_CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, | ||
| CONCENTRATION_PARTS_PER_BILLION as TASMOTA_CONCENTRATION_PARTS_PER_BILLION, | ||
| CONCENTRATION_PARTS_PER_MILLION as TASMOTA_CONCENTRATION_PARTS_PER_MILLION, | ||
| ELECTRICAL_CURRENT_AMPERE as TASMOTA_ELECTRICAL_CURRENT_AMPERE, | ||
| ELECTRICAL_VOLT_AMPERE as TASMOTA_ELECTRICAL_VOLT_AMPERE, | ||
| ENERGY_KILO_WATT_HOUR as TASMOTA_ENERGY_KILO_WATT_HOUR, | ||
| FREQUENCY_HERTZ as TASMOTA_FREQUENCY_HERTZ, | ||
| LENGTH_CENTIMETERS as TASMOTA_LENGTH_CENTIMETERS, | ||
| LIGHT_LUX as TASMOTA_LIGHT_LUX, | ||
| MASS_KILOGRAMS as TASMOTA_MASS_KILOGRAMS, | ||
| PERCENTAGE as TASMOTA_PERCENTAGE, | ||
| POWER_WATT as TASMOTA_POWER_WATT, | ||
| PRESSURE_HPA as TASMOTA_PRESSURE_HPA, | ||
| SENSOR_AMBIENT, | ||
| SENSOR_APPARENT_POWERUSAGE, | ||
| SENSOR_BATTERY, | ||
|
|
@@ -35,12 +48,12 @@ | |
| SENSOR_PROXIMITY, | ||
| SENSOR_REACTIVE_POWERUSAGE, | ||
| SENSOR_STATUS_IP, | ||
| SENSOR_STATUS_LAST_RESTART_TIME, | ||
| SENSOR_STATUS_LINK_COUNT, | ||
| SENSOR_STATUS_MQTT_COUNT, | ||
| SENSOR_STATUS_RESTART, | ||
| SENSOR_STATUS_RESTART_REASON, | ||
| SENSOR_STATUS_RSSI, | ||
| SENSOR_STATUS_SIGNAL, | ||
| SENSOR_STATUS_UPTIME, | ||
| SENSOR_TEMPERATURE, | ||
| SENSOR_TODAY, | ||
| SENSOR_TOTAL, | ||
|
|
@@ -49,21 +62,52 @@ | |
| SENSOR_VOLTAGE, | ||
| SENSOR_WEIGHT, | ||
| SENSOR_YESTERDAY, | ||
| SIGNAL_STRENGTH_DECIBELS as TASMOTA_SIGNAL_STRENGTH_DECIBELS, | ||
| SPEED_KILOMETERS_PER_HOUR as TASMOTA_SPEED_KILOMETERS_PER_HOUR, | ||
| SPEED_METERS_PER_SECOND as TASMOTA_SPEED_METERS_PER_SECOND, | ||
| SPEED_MILES_PER_HOUR as TASMOTA_SPEED_MILES_PER_HOUR, | ||
| TEMP_CELSIUS as TASMOTA_TEMP_CELSIUS, | ||
| TEMP_FAHRENHEIT as TASMOTA_TEMP_FAHRENHEIT, | ||
| TEMP_KELVIN as TASMOTA_TEMP_KELVIN, | ||
| VOLT as TASMOTA_VOLT, | ||
| ) | ||
|
|
||
| from homeassistant.components import sensor | ||
| from homeassistant.const import ( | ||
| CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, | ||
| CONCENTRATION_PARTS_PER_BILLION, | ||
| CONCENTRATION_PARTS_PER_MILLION, | ||
| DEVICE_CLASS_BATTERY, | ||
| DEVICE_CLASS_HUMIDITY, | ||
| DEVICE_CLASS_ILLUMINANCE, | ||
| DEVICE_CLASS_POWER, | ||
| DEVICE_CLASS_PRESSURE, | ||
| DEVICE_CLASS_SIGNAL_STRENGTH, | ||
| DEVICE_CLASS_TEMPERATURE, | ||
| DEVICE_CLASS_TIMESTAMP, | ||
| ELECTRICAL_CURRENT_AMPERE, | ||
| ELECTRICAL_VOLT_AMPERE, | ||
| ENERGY_KILO_WATT_HOUR, | ||
| FREQUENCY_HERTZ, | ||
| LENGTH_CENTIMETERS, | ||
| LIGHT_LUX, | ||
| MASS_KILOGRAMS, | ||
| PERCENTAGE, | ||
| POWER_WATT, | ||
| PRESSURE_HPA, | ||
| SIGNAL_STRENGTH_DECIBELS, | ||
| SPEED_KILOMETERS_PER_HOUR, | ||
| SPEED_METERS_PER_SECOND, | ||
| SPEED_MILES_PER_HOUR, | ||
| TEMP_CELSIUS, | ||
| TEMP_FAHRENHEIT, | ||
| TEMP_KELVIN, | ||
| VOLT, | ||
| ) | ||
| from homeassistant.core import callback | ||
| from homeassistant.helpers.dispatcher import async_dispatcher_connect | ||
| from homeassistant.helpers.entity import Entity | ||
| import homeassistant.util.dt as dt_util | ||
|
|
||
| from .const import DATA_REMOVE_DISCOVER_COMPONENT, DOMAIN as TASMOTA_DOMAIN | ||
| from .discovery import TASMOTA_DISCOVERY_ENTITY_NEW | ||
|
|
@@ -108,10 +152,10 @@ | |
| SENSOR_PRESSUREATSEALEVEL: {DEVICE_CLASS: DEVICE_CLASS_PRESSURE}, | ||
| SENSOR_PROXIMITY: {ICON: "mdi:ruler"}, | ||
| SENSOR_REACTIVE_POWERUSAGE: {DEVICE_CLASS: DEVICE_CLASS_POWER}, | ||
| SENSOR_STATUS_RESTART: {ICON: "mdi:information-outline"}, | ||
| SENSOR_STATUS_LAST_RESTART_TIME: {DEVICE_CLASS: DEVICE_CLASS_TIMESTAMP}, | ||
| SENSOR_STATUS_RESTART_REASON: {ICON: "mdi:information-outline"}, | ||
| SENSOR_STATUS_SIGNAL: {DEVICE_CLASS: DEVICE_CLASS_SIGNAL_STRENGTH}, | ||
| SENSOR_STATUS_RSSI: {ICON: "mdi:access-point"}, | ||
| SENSOR_STATUS_UPTIME: {ICON: "mdi:progress-clock"}, | ||
| SENSOR_TEMPERATURE: {DEVICE_CLASS: DEVICE_CLASS_TEMPERATURE}, | ||
| SENSOR_TODAY: {DEVICE_CLASS: DEVICE_CLASS_POWER}, | ||
| SENSOR_TOTAL: {DEVICE_CLASS: DEVICE_CLASS_POWER}, | ||
|
|
@@ -122,6 +166,30 @@ | |
| SENSOR_YESTERDAY: {DEVICE_CLASS: DEVICE_CLASS_POWER}, | ||
| } | ||
|
|
||
| SENSOR_UNIT_MAP = { | ||
| TASMOTA_CONCENTRATION_MICROGRAMS_PER_CUBIC_METER: CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, | ||
| TASMOTA_CONCENTRATION_PARTS_PER_BILLION: CONCENTRATION_PARTS_PER_BILLION, | ||
| TASMOTA_CONCENTRATION_PARTS_PER_MILLION: CONCENTRATION_PARTS_PER_MILLION, | ||
| TASMOTA_ELECTRICAL_CURRENT_AMPERE: ELECTRICAL_CURRENT_AMPERE, | ||
| TASMOTA_ELECTRICAL_VOLT_AMPERE: ELECTRICAL_VOLT_AMPERE, | ||
| TASMOTA_ENERGY_KILO_WATT_HOUR: ENERGY_KILO_WATT_HOUR, | ||
| TASMOTA_FREQUENCY_HERTZ: FREQUENCY_HERTZ, | ||
| TASMOTA_LENGTH_CENTIMETERS: LENGTH_CENTIMETERS, | ||
| TASMOTA_LIGHT_LUX: LIGHT_LUX, | ||
| TASMOTA_MASS_KILOGRAMS: MASS_KILOGRAMS, | ||
| TASMOTA_PERCENTAGE: PERCENTAGE, | ||
| TASMOTA_POWER_WATT: POWER_WATT, | ||
| TASMOTA_PRESSURE_HPA: PRESSURE_HPA, | ||
| TASMOTA_SIGNAL_STRENGTH_DECIBELS: SIGNAL_STRENGTH_DECIBELS, | ||
| TASMOTA_SPEED_KILOMETERS_PER_HOUR: SPEED_KILOMETERS_PER_HOUR, | ||
| TASMOTA_SPEED_METERS_PER_SECOND: SPEED_METERS_PER_SECOND, | ||
| TASMOTA_SPEED_MILES_PER_HOUR: SPEED_MILES_PER_HOUR, | ||
| TASMOTA_TEMP_CELSIUS: TEMP_CELSIUS, | ||
| TASMOTA_TEMP_FAHRENHEIT: TEMP_FAHRENHEIT, | ||
| TASMOTA_TEMP_KELVIN: TEMP_KELVIN, | ||
| TASMOTA_VOLT: VOLT, | ||
| } | ||
|
|
||
|
|
||
| async def async_setup_entry(hass, config_entry, async_add_entities): | ||
| """Set up Tasmota sensor dynamically through discovery.""" | ||
|
|
@@ -190,9 +258,11 @@ def icon(self): | |
| @property | ||
| def state(self): | ||
| """Return the state of the entity.""" | ||
| if self._state and self.device_class == DEVICE_CLASS_TIMESTAMP: | ||
| return dt_util.as_local(self._state) | ||
|
MartinHjelmare marked this conversation as resolved.
Outdated
|
||
| return self._state | ||
|
|
||
| @property | ||
| def unit_of_measurement(self): | ||
| """Return the unit this state is expressed in.""" | ||
| return self._tasmota_entity.unit | ||
| return SENSOR_UNIT_MAP.get(self._tasmota_entity.unit, self._tasmota_entity.unit) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.