Automation is not passing value to command line

Hello, Im trying so hard and very long time to pass value from automation to commandline

This is what i did.

automation:

  • alias: “test_gsm_1”
    trigger:
    • platform: time_pattern
      minutes: ‘/1’
      condition:
    • condition: state
      entity_id: input_boolean.gsm_test1_on_off
      state: ‘on’
    • condition: template
      value_template: ‘{{ now().strftime("%H:%M") == states.sensor.gsm_test1_time.state }}’
      action:
    • service: shell_command.gsm_test_1
      data_template:
      var1: ‘{{“this is only a test.” | urlencode}}’

command line:

gsm_test_1: “sudo echo ‘Test GSM OK’ | sudo gammu sendsms TEXT 123456789”

Automation work’s, it’s sending sms, but only with command line without passing the variable.
I’ve tried like this

gsm_test_1: “sudo echo {{var1}} | sudo gammu sendsms TEXT 123456789” with many variants of " " and ’ ’ but no effect.

For now, that’s the only thing i totally don’t understant in HA, what’s the point ?

What about trying wammu
I’m not sure if it still working, just give it a try. Otherwise you might try to send the message over the serial with py-serial.
What i mean is that would be better if you can use python to dialog to the phone, so the variables will be preserved.

Hello,
I’ve installed python-gammu, because I thought it would be easiest option, just to run python script.
Unfortunelly in python_scripts i cannot use option import.

That’s how script for python-gammu looks

import gammu

sm = gammu.StateMachine()
sm.ReadConfig()
sm.Init()

message = {
‘Text’: ‘python-gammu testing message’,
‘SMSC’: {‘Location’: 1},
‘Number’: ‘+48123456789’,
}

sm.SendSMS(message)

I’m trying to make my own custom component but it’s only easy to say.
I have installed and running some custom components, and call it from configuration but HA returns error that there’s no right configuration for this component

DOMAIN = ‘sms_gammu’
def setup(hass, config):
import gammu

sm = gammu.StateMachine()
sm.ReadConfig()
sm.Init()

message = {
‘Text’: ‘python-gammu testing message’,
‘SMSC’: {‘Location’: 1},
‘Number’: ‘+48123456789’,
}

sm.SendSMS(message)

I think that component might be very usefull for for other users thats why im planning to share it for every one.
Please help !

I’m also trying to get my component working, but I don’t have the idea how you will get your component working.
So you might look to similar components in <python_path>/(dist|site)-packages/homeassistant/components.
Like this one
Later you should understand how HA is building a service for your component. Maybe one like Ring than you may add your piece of code in that component.

Hello,
Thank’s a lot for interesting of my problem. I’ll try with this. Honestly im confused why nobody else is not using gsm modem and gammu for sending sms messages. Im using my Home Assistant also as security system that’s why i think sms is the best option. My promise is to make the gammu working for 100% with Home Assistant, with full support I mean sending information with prepaid account state via ussd code etc.

By the way today i’ve posted my solution for “peaks” and hanging ds18b20 1wire sensors. You may look at this, hope It will help anybody.
Thank’s for the tip.
Best regards.

Are you using a GSM module for the purpose ?
I think you may get a figure con twillio_sms. The you should override the class and add you funtion to interface the wammu. If wammu is not well suited, you might try to interface just via pyserial and send the commands to the phone in such way.

Definitely you should have already some pythonic experience to get the results.
Currently I’m busy on my case, but I won’t deny you a little support. Except for the hardware interface, which I don’t have.