10#include "../nyx_node_internal.h"
18 if(label == NULL || label[0] ==
'\0')
29 nyx_dict_set_string_unref(result,
"<>",
"defSwitch",
false);
33 nyx_dict_set_string_unref(result,
"@name",
nyx_string_dup(name),
true);
34 nyx_dict_set_string_unref(result,
"@label",
nyx_string_dup(label),
true);
38 nyx_dict_set_string_unref(result,
"$", nyx_onoff_to_str(value),
false);
51 return nyx_dict_set_string(prop,
"$", nyx_onoff_to_str(value),
false);
58 return nyx_str_to_onoff(nyx_dict_get_string(prop,
"$"));
80 nyx_dict_set_string_unref(result,
"<>",
"defSwitchVector",
false);
84 nyx_dict_set_string_unref(result,
"@client",
"unknown",
false);
85 nyx_dict_set_string_unref(result,
"@device",
nyx_string_dup(device),
true);
86 nyx_dict_set_string_unref(result,
"@name",
nyx_string_dup(name),
true);
88 nyx_dict_set_string_unref(result,
"@state", nyx_state_to_str(state),
false);
89 nyx_dict_set_string_unref(result,
"@perm", nyx_perm_to_str(perm),
false);
90 nyx_dict_set_string_unref(result,
"@rule", nyx_rule_to_str(rule),
false);
94 internal_set_opts(result, opts);
98 nyx_dict_set(result,
"children", children);
100 if(props)
for(; *props != NULL; props++)
102 nyx_list_push(children, *props);
104 nyx_object_unref(*props);
107 nyx_object_unref(children);
120 return internal_prop_to_set_vector(vector,
"setSwitchVector",
"oneSwitch");
Struct describing a JSON dict object.
Struct describing a JSON list object.
#define STR_t
Alias for const char *.
__NYX_NULLABLE__ str_t nyx_string_dup(__NYX_NULLABLE__ STR_t s)
Similar to libc strdup.
bool nyx_switch_prop_set(const nyx_dict_t *prop, nyx_onoff_t value)
Sets the new value of the provided property object.
nyx_onoff_t nyx_switch_prop_get(const nyx_dict_t *prop)
Gets the value of the provided property object.
nyx_perm_t
Vector permission hint.
nyx_state_t
Vector state hint.
nyx_rule_t
Switch vector rule hint.
Struct describing the options for INDI / Nyx vectors.