Note that the data is in the format of:
ID/Channel
- The ID is typically 0-511 or 0-127 – it changes when the battery is changed
- The Channel though shouldn’t change and is typically a 2-bit number (the above applies to the devices I use)
You can find the values of OR IG in multiple places.
Using the CLI:
/homeassistant/.storage/core.device_registry
- Also in
core.entity_registry
, core.restore_state
or anywhere device or entity name is mentioned
- ``states_meta
table of
home-assistant_v2.db`
Using the GUI GUI, you can look under devices
or entities
Under Settings->Devices & Services
To find the value for “NEW”
Assuming you have MQTT discovery shut off so that you haven’t created new devices and entities for the sensors, you can use MQTT Explorer
either as an add-on to HA or as a standalone app to see the name of the device being posted to your MQTT broker. Alternatively, you can run ` mosquitto_sub -h “$HOST” -u “$USER” -P “$PASSWD” -t ‘home/#’ to see all the devices being posted. You may need to wait a few minutes for your sensor to post data.
mosquitto_sub
and mosquitto_pub
should be part of the Mosquitto Broker
add-on. I access it using the Advanced SSH
add-on.
If you are not familiar and comfortable with BASH and SSH, I would advice caution before running such a 1-liner.
Also I would suggest using MQTT Explorer to make sure the format of your device names matches (and especially the device id & channel) match the format assumed in my 1-liner.
NOTE: If you have changed the battery and accidentally left discovery on, then assuming you haven’t collected too much data yet under the new device, you may want to delete the new device using my delete_device
routine (see 6 Routines to Delete/Rename/Move Devices & Entities and their corresponding registry entries, data, and metadata - #7 by puterboy). Just be sure to shut off auto-discovery first. After deleting the newly created devices, use the rename_device+entities
routine to rename the old device plus associated entities.
If you have already collected a lot of data under the new device, then you can manually use sql CLI commands to move the data from the old metadata_id to the new one (you would need to do this for the states
, statistics
, and statistics_short_term
tables) – this is all manual SQL fu so be VERY careful if you have to go this path.
If you are using my scripts make sure to look at the VARIABLES section of each script to see if you need to change any variables. Also, make sure you have the latest versions.
Better yet, scan the script to make sure you understand and are comfortable with all it does.
BEWARE WHILE THE SCRIPT HAS MANY CHECKS AND BY DEFAULT CREATES COPIOUS BACKUPS, IT MODIFIES THE HA DB AND REGISTRY FILES SO IT COULD CAUSE IRREPARABLE DAMAGE TO YOUR SYSTEM, REQUIRING RESTORE FROM BACKUP.