Simulated sensor


This component provides a simulated sensor that generates a time-varying signal V(t) given by the function:

 V(t) = M + A sin((2 pi (t - t_0) / w) + P) + N(s)

where:

  • M = the mean value of the sensor
  • A = the amplitude of the periodic contribution
  • t = the time when a value is generated
  • t_0 = the time when the sensor is started
  • w = the time period in seconds for a single complete cycle of the periodic contribution
  • P = the phase offset to add to the periodic contribution, in units of degrees
  • N(s) = the random Gaussian noise with spread s

A simulated sensor with default values can be added to home-assistant using the following config:

sensor:
  - platform: simulated

To give an example of simulating real world data, a simulated relative humidity sensor (in %) can be added using the following config:

sensor:
  - platform: simulated
    name: 'simulated relative humidity'
    unit: '%'
    amplitude: 0 # Turns off the periodic contribution
    mean: 50
    spread: 10
    seed: 999

Configuration variables:

Configuration Variables

name

(string)(Optional)The name of the sensor

Default value: Defaults to ‘simulated’

unit

(string)(Optional)The unit to apply

Default value: Defaults to ‘value’

amplitude

(float)(Optional)The amplitude of periodic contribution

Default value: 1

mean

(float)(Optional)The mean level of the sensor

Default value: 0

period

(seconds)(Optional)The time in seconds for one complete oscillation of the periodic contribution

Default value: 0

phase

(float)(Optional)The phase offset (in degrees) to apply to the periodic component

Default value: 0

seed

(int)(Optional)The seed value for the random noise component

Default value: 999

spread

(float)(Optional)The spread is the range of the randomly distributed values about their mean. This is sometimes referred to as the Full Width at Half Maximum (FWHM) of the random distribution

Default value: None