Data Retention

Is there a way to create a statistics type entity via helpers?
I.e. at the moment I have an input_number but honestly it could be anything that can be updated…

I’m not aware of any way to explicitely set the state class on input numbers. You may have to use a template sensor as an intermediate.

How would one go about doing that?
If it helps I already have a sensor which I’m using for UI representation (sensor.input_number_name) to remove the unneeded decimal point

I get this error when I try to add a data-source according to the video above

image

Hello, I would like to ask, if I want to retention only 2 sensor for 30 days, so this config correct?

recorder:
  purge_keep_days: 30
  include:
    entities:
      - sensor.sma_daily_yield_wh

And other sensor keep retention default 10 days?

That’s not possible. You can only set days for the whole database.

Petro, Thank You your answer.

When I’ve setup mariaDB on my nas, how do I change the retention to infinite?
Maybe I missed the reply here. But is it then 0 for infinit or do I need to fix that different?

and although this has gone stale, if i set up recorder to use an external DB does that include the history and the statistics… My DB runs on an external NVME server so im not worried about disk performance. I currently running an alternative HA solution nad its got 5 years worth of data, which i do occasionally go back to…

Just a question, reading this topic and thinking out of the box.
When I add a MQTT Sensor configured by Node-Red, for example:

The function node contains:
(this is a working setup I wrote to add any virtual sensor and used for more then a year. BTW dont just copy/paste because logTimeStamp is a custom variable.)

var logTimeStamp = global.get('logTimeStamp')||"No Timestamp";
var _topicBase = "homeassistant";
var _topicComponent = "sensor"
var _topicNodeId = "presence";
var _topicDeviceName = "detection";
var _topic = _topicBase + "/" + _topicComponent + "/" + _topicNodeId + "/" + _topicDeviceName
var _qos = 2;
var _retain = true;
var _payload = {
    "name": "Presence Detection",
    "icon": "hassio:eye-outline",
    "unique_id": "mqtt_presencedetection",
    "has_entity_name": "true",
    "node_id": _topicNodeId,
    "state_topic": _topic + "/state",
    "device": {
        "name": "Mqtt Security",
        "manufacturer": "MQTT Hass.io",
        "model": "Custom",
        "identifiers": ["Mqtt Security"],
        "sw_version": "20230803",
        "suggested_area": "Algemeen"
        }
    };
if (msg.payload === '' ){
     node.status({fill:"red",shape:"dot",text: logTimeStamp + " " + _topic});
     _topic = _topic + "/config";
     _qos = 0;
     _retain = false;
     _payload = '';
    } else {
     node.status({fill:"green",shape:"dot",text: logTimeStamp + " " + _topic});
     _topic = _topic + "/config";
    }    
var message = {
    topic: _topic,
    qos: _qos,
    retain: _retain,
    payload: _payload
};
return message;

The MQTT device is using (as an example) just four states: “home”, “away”, “sleep”, “holliday”.

The question, can I add, at the var _payload config, to get the four states to be stored in the long-term-statistics? :

¨device_class": "enum",
"options": {}

If so, how do I configure the options list and can this be a way to do it?
Any idea?