Volume control Windows PC by calling URL

Hey, guys. I’m trying to figure out, how can I turn on switches by input_number (slider) values. Maybe it’s an odd solution, but I want to do it with url function for many reasons. URLs are working. I do not know, how can I configure Automations. For example: I want to turn on switch pc_volume_0 by slider value “0”… or when I choose value 5 on slider I want to turn on switch pc_volume_5. etc… This is my configuration:

input_number:
  slider_zvuk:
    icon: mdi:volume-high
    name: Volume
    initial: 100
    min: 0
    max: 100
    step: 5


- platform: command_line
  switches:
    pc_volume_0: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol000"
    pc_volume_5: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol005"
    pc_volume_10: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol010"
    pc_volume_15: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol015"
    pc_volume_20:
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol020"    
    pc_volume_25: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol025"
    pc_volume_30: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol030"
    pc_volume_35:
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol035"    
    pc_volume_40: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol040"
    pc_volume_45: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol045"
    pc_volume_50:
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol050"
    pc_volume_55: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol055"
    pc_volume_60: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol060"
    pc_volume_65: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol065"
    pc_volume_70: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol070"
    pc_volume_75:
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol075"   
    pc_volume_80: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol080"
    pc_volume_85: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol085"
    pc_volume_90:
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol090"    
    pc_volume_95: 
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol095"
    pc_volume_100:
      command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol100"  

- alias: PC Volume
  trigger:
    - platform: state
      entity_id: input_number.slider_zvuk
  action:
    - service: switch.turn_on
      data_template:
        entity_id: switch.pc_volume_{{ trigger.to_state.state | int }}

Thanks a lot in advance.

Finally I figured out this problem! This is a final solution for you guys, if you have similar project:

# Volume Windows
shell_command:
  pc_volume_0: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol000"
  pc_volume_5: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol005"
  pc_volume_10: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol010"
  pc_volume_15: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol015"
  pc_volume_20: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol020"    
  pc_volume_25: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol025"
  pc_volume_30: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol030"
  pc_volume_35: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol035"    
  pc_volume_40: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol040"
  pc_volume_45: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol045"
  pc_volume_50: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol050"
  pc_volume_55: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol055"
  pc_volume_60: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol060"
  pc_volume_65: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol065"
  pc_volume_70: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol070"
  pc_volume_75: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol075"   
  pc_volume_80: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol080"
  pc_volume_85: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol085"
  pc_volume_90: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol090"    
  pc_volume_95: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol095"
  pc_volume_100: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol100"  

script:
 volume_script:
  alias: Volume Script
  sequence:
    - service_template: >
        {% if states.input_number.slider_zvuk.state | int == 100.0 %}
          shell_command.pc_volume_100
        {% elif states.input_number.slider_zvuk.state | int == 95.0 %}
          shell_command.pc_volume_95
        {% elif states.input_number.slider_zvuk.state | int == 90.0 %}
          shell_command.pc_volume_90
        {% elif states.input_number.slider_zvuk.state | int == 85.0 %}
          shell_command.pc_volume_85
        {% elif states.input_number.slider_zvuk.state | int == 80.0 %}
          shell_command.pc_volume_80
        {% elif states.input_number.slider_zvuk.state | int == 75.0 %}
          shell_command.pc_volume_75
        {% elif states.input_number.slider_zvuk.state | int == 70.0 %}
          shell_command.pc_volume_70
        {% elif states.input_number.slider_zvuk.state | int == 65.0 %}
          shell_command.pc_volume_65
        {% elif states.input_number.slider_zvuk.state | int == 60.0 %}
          shell_command.pc_volume_60
        {% elif states.input_number.slider_zvuk.state | int == 55.0 %}
          shell_command.pc_volume_55
        {% elif states.input_number.slider_zvuk.state | int == 50.0 %}   
          shell_command.pc_volume_50
        {% elif states.input_number.slider_zvuk.state | int == 45.0 %}
          shell_command.pc_volume_45
        {% elif states.input_number.slider_zvuk.state | int == 40.0 %}
          shell_command.pc_volume_40
        {% elif states.input_number.slider_zvuk.state | int == 35.0 %}
          shell_command.pc_volume_35
        {% elif states.input_number.slider_zvuk.state | int == 30.0 %}
          shell_command.pc_volume_30
        {% elif states.input_number.slider_zvuk.state | int == 25.0 %}
          shell_command.pc_volume_25
        {% elif states.input_number.slider_zvuk.state | int == 20.0 %}
          shell_command.pc_volume_20
        {% elif states.input_number.slider_zvuk.state | int == 15.0 %}
          shell_command.pc_volume_15
        {% elif states.input_number.slider_zvuk.state | int == 10.0 %}
          shell_command.pc_volume_10
        {% elif states.input_number.slider_zvuk.state | int == 5.0 %}
          shell_command.pc_volume_5
        {% elif states.input_number.slider_zvuk.state | int == 0.0 %}   
          shell_command.pc_volume_0  
        {% else %}
          // Zadna jina moznost neni :)
        {% endif %}

automation:
 - id: 'pc_volume'
   alias: PC Volume
   initial_state: 'on'
   trigger:
    - entity_id: input_number.slider_zvuk
      platform: state
   action:
    - service: script.volume_script


      
# MUTE Windows  
switch:   
   - platform: command_line
     switches:
        pc_volume_mute:
          friendly_name: MUTE
          command_on: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=Vypnout%20zvuk"
          command_off: curl -X POST "http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=Zapnout%20zvuk"
1 Like

Hello Mr. Art

I would like to do the same. The HASS side is clear to me but could you share more info about the PC settings? What kind of sw do you use?

i.e: http://192.168.1.10:8000/?action=Shell.ExecutePredefined&command=vol020

Thanks
Tony

I would like to know this as well

I believe it’s Airytec Switch Off (yeah, because it also uses port 8000), which gives you a local network accessible page, where you can launch scripts on windows on specific URLs by accessing them. I currently use it for standby command, but I think I’ll add volume and screen brightness controls (this with the commands for ClickMonitorDDC).