Skip to content

Instantly share code, notes, and snippets.

@BenniG82
BenniG82 / pom.xml
Created January 4, 2024 09:16
Minimal pom.xml causing different false positives on different systems
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.bennig</groupId>
<version>0.0.1-SNAPSHOT</version>
<artifactId>pomtest</artifactId>
<name>pomtest</name>
@BenniG82
BenniG82 / fix_homeassistant_statistics.sql
Created November 19, 2023 17:48
This code snippet is designed to identify "corrupted" data in Home Assistant statistics and generates (without executing) update scripts to repair these statistics and the statistics_short_term data.
/*
This code snippet is designed to identify "corrupted" data in Home Assistant statistics and generates (without executing) update scripts to repair these statistics and the statistics_short_term data.
*Note: "Corrupted" here refers to instances where statistics were unintentionally reset to a sum of 0.
At present, this functionality is limited to cases where the corruption did not happen within the timeframe covered by the statistics_short_term data. However, the script can be modified to address such scenarios.
*/
select id, created, statistic_id, metadata_id, sum, oldsum, sum / oldsum,
'update statistics set sum=sum + ' || oldsum || ' where id >= ' || id || ' and metadata_id = ' || metadata_id || ';',