Added more devices and types to onewire#9404
Conversation
| device_files = [] | ||
| devs = [] | ||
| device_names = {} | ||
| if 'names' in config.keys(): |
There was a problem hiding this comment.
No need to add .keys() to test if a key exists.
| def __init__(self, name, device_file, stype): | ||
| """Initialize the sensor.""" | ||
| self._name = name | ||
| self._name = name+' '+stype |
There was a problem hiding this comment.
This means that it is no longer possible for people to override the name. We should only append the type if no name was given.
There was a problem hiding this comment.
The solution in the earlier code led to some issues with assigning the correct values to the right type. Should be ok to just remove this change now.
There was a problem hiding this comment.
Oh, and removing the change should also lead to removing breaking change status I guess.
| def update(self): | ||
| """Get the latest data from the device.""" | ||
| temp = -99 | ||
| value = -99 |
There was a problem hiding this comment.
Sure, I just went with what was there. Will update.
balloob
left a comment
There was a problem hiding this comment.
Nice work! Just a couple of comments.
Since it is changing the default names, it will also influence how entity ids are generated. This makes this a breaking change. Please add a paragraph in your PR description how users are impacted and how to upgrade.
|
As the name change is not really necessary, I will remove the change. |
|
Ok, it looks like it does not work the way I thought. I figured that HA would put values of the same _type always in the same bucket regardless if the names are the same. It does not appear to be the case. I now get millibar values in the temperature chart under history. |
|
Added the change back and updated the description. Does it look ok? |
|
Please make sure to submit a PR with updated documentation |
|
That is the current documentation, it however does not contain the addition that you just made. Please make sure that when you open a PR you do it against the |
Description:
Added support for humidity and pressure in 1-wire devices. Also added support for a couple of new (old) devices.
This update changes the names of the sensors from "<sensor_name>" to "<sensor_name> <Sensor_type>"
Example: Kitchen -> Kitchen Temperature.
In the database this looks like: sensor.kitchen -> sensor.kitchen_temperature.
This was a necessary change as devices with multiple sensors would be given additional _n suffixes in the database that would be not be persistent per sensor across restarts of HA.
If you wish to maintain a single line of record in the database this can be achieved by the following recipe.
Connect to your database using the instructions from https://home-assistant.io/docs/backend/database/
Check the names of sensors:
SELECT entity_id, COUNT(*) as count FROM states GROUP BY entity_id ORDER BY count DESC LIMIT 10;
Alter the names of sensors using the following examples:
UPDATE states SET entity_id='sensor.<sensor_name>_temperature' WHERE entity_id LIKE 'sensor.<sensor_name>%' AND attributes LIKE '%\u00b0C%';
UPDATE states SET entity_id='sensor.<sensor_name>_pressure' WHERE entity_id LIKE 'sensor.<sensor_name>%' AND attributes LIKE '%mb%';
UPDATE states SET entity_id='sensor.<sensor_name>_humidity' WHERE entity_id LIKE 'sensor.<sensor_name>%' AND attributes LIKE '%%%' ESCAPE '';
Remember to replace <sensor_name> with the actual name of the sensor as seen in the SELECT query.
Checklist:
If the code communicates with devices, web services, or third-party tools:
toxrun successfully. Your PR cannot be merged unless tests passREQUIREMENTSvariable (example).requirements_all.txtby runningscript/gen_requirements_all.py..coveragerc.