Package: vscp-python-send-heartbeat
send-mqtt-heartbeat and send-vscp-heartbeatTwo scripts that help to send VSCP heartbeats from remote machines. One version is for sending VSCP heartbeats over MQTT and the other for sending VSCP heartbeats over the tcp/ip link protocol.InstallationYou can either download the scripts from this repository (https://github.com/grodansparadis/vscp-python-send-heartbeat) or install them from the package manager. If you download from the repository you need to install the dependencies yourself.The far easiest eay is to install withpip. The only thing needed to install the pyhon package is the following:pip3 install vscp-python-send-heartbeatbest is to install in a virtual environment. Use the following command to create a virtual environment:mkdir project-name && cd project-name
python3 -m venv .env
source .env/bin/activatethe do the install of the package as described above.After install you can use bot scripts,send-vscp-heartbeat.pyandsend-mqtt-heartbeat.py, from the command line. Info on how to configure the scripts for your needs are below.send-mqtt-heartbeatSend VSCP heartbeat to a MQTT broker (typically used in a cron job)Usage./send-mqtt-heartbeat.py--broker=host-n--topic="/vscp"[--guid=""]This will send a json formattedheartbeat eventto the selected MQTT broker. You can set zone and subzone and also data byte zero content.If a guid is not specified a GUID will be constructed from the machines MAC address. Seethe specificationfor more information on this.The default topic is"vscp/{xguid}/{xclass}/{xtype}"where {xguid} is replaced with the actual GUID and {xclass} is replaced with the VSCP class and {xtype} is replaced with the actual VSCP type.The-nsays that username and password should be fetched from the.netrcfile. SeeUse .netrcbelow.Short parameterLong parameterDescription-h--helpShow help text-v--verbosePrint output also to screen.-c--configPath to configuration file (--config="some path").-b--brokerBroker to connect to (--broker="demo.vscp.org").-p--portPort on broker to connect to (--port=1883).-u--userUsername to use as credentials (--user=admin).-P--passwordPassword to use as credentials (--password=secret).-g--guidGUID to use for event (--guid=FF:FF:FF:FF:FF:FF:FF:FE:60:A4:4C:E7:76:5A:00:00).-t--topicTopic to publish heartbeat on (-topic=the_fabulous_topic).-0--byte0Set optional byte 0 (--byte0=11).-z--zoneSet zone (--zone=22).-s--subzoneSet subzone (--subzone=33).Example./send-mqtt-heartbeat.py--broker=test.mosquitto.org-n-v-t="/vscp/FF:FF:FF:FF:FF:FF:FF:FE:60:A4:4C:E7:76:5A:00:00/20/9"will send a VSCPheartbeatevent to the MQTT mosquitto test broker using the specified topic.Example./send-mqtt-heartbeat.py-v-c"./config.ini"will send a VSCPheartbeatevent to the broker specified in the configuration file.Typically used in a cron job.*****rootcd/root;./send_mqttheartbeat.py-nsend-vscp-heartbeatSend VSCP heartbeat to a VSCP daemon or send (typically used in a cron job)Usage./send-vscp-heartbeat.py--server=host-n[--guid=""]This will send aheartbeat eventto the selected VSCP sever. You can set zone and subzone and also data byte zero content.If a guid is not specified a GUID will be constructed from the machines MAC address. Seethe specificationfor more information on this.The-nsays that username and password should be fetched from the.netrcfile. SeeUse .netrcbelow.Short parameterLong parameterDescription-h--helpShow help text-v--verbosePrint output also to screen.-c--configPath to configuration file (--config="some path").-b--serverServer to connect to (--server="demo.vscp.org").-p--portPort on broker to connect to (--port=1883).-u--userUsername to use as credentials (--user=admin).-P--passwordPassword to use as credentials (--password=secret).-g--guidGUID to use for event (--guid=FF:FF:FF:FF:FF:FF:FF:FE:60:A4:4C:E7:76:5A:00:00).-0--byte0Set optional byte 0 (--byte0=11).-z--zoneSet zone (--zone=22).-s--subzoneSet subzone (--subzone=33).Example./send-vscp-heartbeat.py--broker=test.mosquitto.org-n-v-t="/vscp/FF:FF:FF:FF:FF:FF:FF:FE:60:A4:4C:E7:76:5A:00:00/20/9"will send a VSCPheartbeatevent to the MQTT mosquitto test broker using the specified topic.Example./send-vscp-heartbeat.py-v-c"./config.ini"will send a VSCPheartbeatevent to the host specified in the configuration file.Typically used in a cron job.Use .netrcThe switch-nor--netrcsays that username and password should be fetched from the.netrcfile in the executing user's home directory. This file should only be readable by the owner no one else. The format ismachine host1 
login user1 
password pass1

machine host2 
login user2 
password pass2which also can be written asmachine host1 login user1 password pass1
machine host2 login user2 password pass2The command line argument´´´
--broker=hostor--server=host
´´´select the entry (can also be given as-bhost).This is the secure way to use the script not exposing any credentials. Another alternative is to store this information in the configuration file and set proper access rights for this file. The insecure way is to enter the credentials on the command line which even if supported is not secure.Configuration file formatA typical configuration file have the following content. The content should be selfexlpratory.# Configuration file example for send_mqtt_heartbeat.py and send_vscp_heartbeat.py

[GENERAL]

# Show info when the script is eceuted
bVerbose = True

# GUID to use for heartbeat event
# If empty MAC address will be used to construct GUID
guid=

# Optional byte zero to use for heartbeat event
byte0=0

# Zone to use for heartbeat event
zone=80

# Subzone to use for heartbeat event
subzone=0

[VSCP]

# The VSCP daemon to connect to.
# If .netrc is used this should be the machine name.
host = vscp

# (comment out if using .netrc)
user = vscp

# (comment out if using .netrc)
password = secret

[MQTT]
# MQTT host address
host=mqtt

# MQTT host port
port=1883

# MQTT username (comment out if using .netrc)
user=vscp

# MQTT password (comment out if using .netrc)
password=secret

# Topics for VSCP JSON event publishing
topic_temperature=vscp/{xguid}/{xclass}/{xtype}This file is part of the VSCP project (https://www.vscp.org)