Tidying up the battery type & quantity #421
              
  
  Closed
              
          
                  
                    
                      andrew-codechimp
                    
                  
                
                  started this conversation in
                General
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
When I first created battery notes I had one field for a battery note, which I used for either the battery type or a combination of the type and quantity, CR2042 or 2x AA
As things progressed this was a mistake, behind the scenes I should have had separate config entries for each type and quantity to allow for some future features.
What I'll be doing over 2 releases is making this change.
First I'll be adding two new attributes to battery_type and using a regex to split the quantity and type (no leading #x then it'll be 1). This will allow me to test that code is working without error though as attributes are not that visible within HA I doubt many will notice.
Second I'll be migrating the current config to two separate fields using that same regex. When adding new devices, editing existing or during discovery you'll now get two separate entry fields for type and quantity.
If all goes well this shouldn't cause any issues for anyone that uses the example stated of 2x AA but if you have your quantity in a different format it won't transfer correctly and you'll have 1x 2 of AA as an example which will require a manual edit.
Beta Was this translation helpful? Give feedback.
All reactions