Help using automation to pass input_number to shell_command

Friends, I am a real newbie here but am just trying to have a minor success in changing my direcTV channel from HA. I am running hassio 0.61 on a pi3. Here is my configuration.yaml:

homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
 latitude: !secret sec_latitude
 longitude: !secret sec_longitude
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 90
# metric for Metric, imperial for Imperial
unit_system: imperial
  # Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: America/Chicago
  # Customization file
 customize: !include customize.yaml

# Show links to resources in log and frontend
introduction:

# Enables the frontend
frontend:

# Enables configuration UI
config:

http:
   # Secrets are defined in the file secrets.yaml
  api_password: !secret http_password
  # Uncomment this if you are using SSL/TLS, running in Docker container, etc.
  # Example configuration.yaml entry for the HTTP component
   # ssl_certificate: fullchain.pem
  #  ssl_key: privkey.pem

# Checks for available updates
#Note: This component will send some information about your system to
#the developers to assist with development of Home Assistant.
#For more information, please see:
#https://home-assistant.io/blog/2016/10/25/explaining-the- updater/
updater:
#Optional, allows Home Assistant developers to focus on popular components.
# include_used_components: true

#Discover some devices automatically
discovery:

#Allows you to issue voice commands from the frontend in     enabled browsers
conversation:

#Enables support for tracking state changes over time
history:

#View all events in a logbook
logbook:

#Enables a map showing the location of tracked devices
map:

#Track the sun
sun:

#Weather prediction
sensor:
  - platform: yr

#Text to speech
tts:
- platform: google



#Cloud
cloud:

media_player:
  - platform: directv
    host: 192.168.1.113
    port: 8080
    name: Main DirecTV Box
    device: 0

  - platform: directv
    host: 192.168.1.113
    port: 8080
    name: Bedroom DirecTV
    device: 403DECCE6596

input_number:
  box1:
    name: channel
    initial: 2
    min: 0
     max: 1000
    step: 1
    mode: box


climate:
- platform: honeywell
  username: !secret hon_username
  password: !secret hon_password
  scan_interval: 600
  region: us

##...snipped out TV section as it is very long...

shell_command:
  dtv_channel: 'curl -X GET http://192.168.1.113:8080/tv/tune?major={{channel}}&minor=65535&clientAddr=403DECCE6596'

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml

My automation file:

 - alias: directv_change_channel
   trigger:
   - entity_id: input_number.box1
     platform: state
  action:
  - service: shell_command.dtv_channel
  data:
    #channel: '202' ***This one worked**
    #channel: 'input_number.box1.channel'
    #channel: 'input_number.box1.state'
    #channel: '{{ states(input_number.box1) }}' 
    #channel: 'channel'
    #channel: input_number.box1
    #channel: 'input_number.box1
    channel: "{{ states.input_number.box1.state }}"


#data_template:
  #channel: '206' ***This one worked***
  #channel: '{{ states.input_number.box1.state }}' 
  #channel: '{{ state(input_number.box1) }}' 
  #channel: '{{ states(input_number.box1) }}'
  #channel: '{{ states(input_number.box1) }}'      
condition: []
id: '1515771156944'

Everything seems to work fine when I hard code the channel. However, you can see everything I have tried to get the variable channel to be set to the value of the input_number. I am really trying to learn here, what troubleshooting steps should I be taking? In other environments, I would view the value of the variable as I am calling the function, but I haven’t figured out how to do that here.
(edit: I also have know idea why the formatting of my message is dorked up)
(edit: I have edited to use preformatted text but it did not help much. Ok finally got it looking better…)
montyhp

Post your code using the </> on the text box.

I tried that but it didn’t fix the superlarge comment text.

1 Like

Should be fixed now

I have it working now. Here is the automation file:

 - alias: directv_change_channel
   trigger:
   - entity_id: input_number.box1
     platform: state
   action:
   - service: shell_command.dtv_channel
     data_template:
        channel: "{{ trigger.to_state.state | int }}"#Works!      
 
  condition: []
  id: '1515771156944'