Sensordata stored in input_number

Greetings from Denmark. :smiley:
I am tinkering around with my floorplan for my iphone 11 max pro screen:
And now the time has come for a weather forecast configuration:

I want to store data in an input_number from a sensor.

(Later on in my floorplan config:
This data is being used to compaire a xiaomi realtime sensor data to data form three hours ago stored in an input_number. the two icons on the picture and the green arrow will change according to Realtime data and data from 8 hours ago)

veatherforecast

I think that i have almost got it, but input _number.barometerdatareadings don’t change to sensor.pressure_lumi_158d00022cc292 value

Here are my code . Any suggestion’s how to fix it?:slightly_smiling_face:

inbut_number in input_number.yaml

in configuration i added input_number.yaml to configuration.yaml like so:

input_number: !include input_number.yaml

## xiaomi aripressure data stored in this input_number.  
barometerdatareadings: 
    name: 'Barometerdata input'
    # mode: box
    min: 960
    max: 1060
    step: 0.1

Sensor:

    barometerstand:
      friendly_name: "Barometric data without decimals"
      unit_of_measurement: 'hPa'
      value_template: >-
        {{ states('sensor.pressure_lumi_158d00022cc292')|int }}

Automation:
The first 3 platform: time is for testing

At a given time i need sensor.barometerstand to pass on its value to input_number.barometerdatareadings
( barometerstand means barometer reading in danish)
{{(states(‘sensor.barometerstand’) |float }} Result type: number 1021
{{ (states(‘input_number.barometerdatareadings’)) }} Result type: number 960

The reading I get now is 960 ( min: 960) from input_number configuration

- id: airpressurereadings
  alias: air pressure readings every 8 hours 
  trigger:
    - platform: time
      at: '19:47:00'
    - platform: time
      at: '20:00:00'
    - platform: time
      at: '20:30:00'
    - platform: time
      at: '08:00:00'
    - platform: time
      at: '16:00:00'
    - platform: time
      at: '24:00:00'

  action:
    - service: input_number.set_value
      data_template:
        entity_id: input_number.barometerdatareadings
        value: "{{(states('sensor.barometerstand')) |float }}"

What do you try to achieve with the extra sensor template in-between? Why not use sensor.pressure_lumi_158d00022cc292 directly in the automation?

Hi S.

I need sensor.pressure_lumi_158d00022cc292 from 8 hours ago compared to the realtime sensor.pressure_lumi_158d00022cc292. I am sure it can be done in an automation, but I am not a coding shark, so i came up with the solution to store the sensorvalue in an input_number. Then I will make another sensor that compares the two values and give me new senson.
The new sensor triggers an input_boolean. This input_boolean goes on and off in the floorplan and will show an icon.

pressure 960 - 1000 = rain icon
pressure 1000 - 1010 cloudy icon
and so on…

I get why you would like to have the input_number, I don’t get why you don’t fill it with data from sensor.pressure_lumi_158d00022cc292 directly.

This just gives you a copy of the sesnor.

    barometerstand:
      friendly_name: "Barometric data without decimals"
      unit_of_measurement: 'hPa'
      value_template: >-
        {{ states('sensor.pressure_lumi_158d00022cc292')|int }}

Yes I know made to an integer.
This is the reading i get from the input_number:

and the sensor :smiley:

Just make your life easy and do that when making the service call to input_number.set_value :wink:

But apart from the old (deprecated) data_template I see nothing wrong with the automation. But running it does noting? Or is it not starting?

Without data_template and directly in the automation the rounding

alias: air pressure readings every 8 hours
description: ''
mode: single
trigger:
  - platform: time
    at: '8:00:00'
  - platform: time
    at: '16:00:00'
  - platform: time
    at: '24:00:00'
condition: []
action:
  - service: input_number.set_value
    target:
      entity_id: input_number.barometerdatareadings
    data:
      value: '{{ states(''sensor.pressure_lumi_158d00022cc292'')|float|round(0)}}'

How do i do that?

ok thanks. I will try that :smiley:

and testing… :slightly_smiling_face:

  trigger:
    - platform: time
      at: '21:35:00'
    - platform: time
      at: '21:40:00'
    - platform: time
      at: '21:50:00'

my automation dont show up in Entity list:

any reason why?

- id: airpressurereadingstwo
- alias: "air pressure readings every eight hours" 
  trigger:
    - platform: time
      at: '21:40:00'
    - platform: time
      at: '22:50:00'
    - platform: time
      at: '22:31:00'
    - platform: time
      at: '08:00:00'
    - platform: time
      at: '16:00:00'
    - platform: time
      at: '24:00:00'
  action:
    service: input_number.set_value
    target:
      entity_id: input_number.barometerdatareadings
    data:
      value: '{{ states("sensor.pressure_lumi_158d00022cc292")|float|round(0)}}'

Because the automation’s syntax is incorrect. Look at the automation’s first two lines, do you see the mistake?

If you don’t: Remove the hyphen from the second line and replace it with a space.

If you wish, you can consolidate the multiple Time Triggers.

- id: airpressurereadingstwo
  alias: "air pressure readings every eight hours" 
  trigger:
    - platform: time
      at: 
      - '21:40:00'
      - '22:50:00'
      - '22:31:00'
      - '08:00:00'
      - '16:00:00'
      - '24:00:00'
  action:
    service: input_number.set_value
    target:
      entity_id: input_number.barometerdatareadings
    data:
      value: '{{ states("sensor.pressure_lumi_158d00022cc292")|float|round(0)}}'

I ended up doing this config. Now I just have to test and wait :grinning:
Thanks for inputs!!
Very simple solution and I learned a bit more about YAML.

- id: airpressurereadingstwo
  alias:  air pressure readings every eight hours
  trigger:
    - platform: time
      at: 
      -  "03:15:00"
      -  "03:25:00"
      -  "03:35:00"
      -  "08:00:00"
      -  "16:00:00"
      -  "24:00:00"
  action:
    service: input_number.set_value
    target:
      entity_id: input_number.barometerdatareadings
    data:
      value:
        '{{ states("sensor.pressure_lumi_158d00022cc292")|float|round(0)}}'

You should be aware that the custom of this community is assign the Solution tag to the post that introduces the idea or example that solves the original problem.

In this case, you simply copied what I had suggested and then marked your own post as the Solution. The only thing you changed are the trigger times but that has nothing to do with solving the original problem.

Sorry…not my intension.
could not have done it without your help!! :wink:
“error fixed”

1 Like

edit:
managed to solve the problem. i had to use Input_Text helper instead of input_number. After that reformat the string from the sensor reading to float. works now

sorry for digging this up but i am having problem w the syntax here it seems

i want to store the current volume level of my AVR in an input number to later restore it, so i am trying to store the sensor’s data in an input number like so:

alias: denon_store_volume
description: ""
triggers:
  - type: changed_states
    device_id: 8e505cc550cbc82174a7ab90fb662ec0
    entity_id: 7f774953bab03ed3dea03e53c5a9c0a3
    domain: media_player
    trigger: device
conditions: []
action:
  service: input_number.set_value
  target:
    entity_id: input_number.denon_last_volume
  data:
    value: '{{states('sensor.compensation_media_player_denon_avr_3312_volume_level') }}'
mode: single

alas this doesn’t work:
“Message malformed: Service does not match format . for dictionary value @ data[‘actions’][0][‘action’]”